Sorting an array in Simulink - simulink

I want to sort a given array in ascending order. Is there any block in Simulink which does this?
If no, how to do this most efficiently using common Simulink blocks? I understand this could be done using Stateflow but just wanted to know how to do in Simulink.
Thanks!

If you have DSP System toolbox, there is a Sort block available under statistics library. Otherwise you need to use MATLAB Function block as suggested by am304.

Use a MATLAB Function block in conjunction with the sort function. I think that block supports matrix inputs.

Related

Simbiology toolbox and fmincon in MATLAB

Is is possible to use the model simulated in the Simbiology toolbox of Matlab
to be used to implement fmincon for the same by calling the model from Simbiology?
It is possible to simulate the SimBiology model from a MATLAB script or the command line (see sbiosimulate). This allows the simulation results to be used by any other MATLAB function as needed. I assume that in your case you want to use the simulation results to construct an objective function to use with fmincon and it is possible. Let me know if you need more details.
The short answer is probably, yes. If you have access to the tools and try this, let me know and we can help further.

Designing a Matlab filter from a Laplace equation

I have a Laplace Transfer function that I wish to use in a high pass filter. I am trying to design a filter inside Matlab that will use this function using FDAtool but I don't understand how the parameters and coefficients this tool uses relates to the Laplace function I have.
Can anyone provide some information or links regarding the relationship between a function and the filter that uses it.
Why don't you simply use a Transfer Fcn block (or a Discrete Transfer Fcn block if it's discrete) since you already have the Laplace transfer function? FDAtool is for designing a filter as far as I know. It sounds like your filter is already designed.

is it possible to use cell array in matlab function block in simulink?

i have a Structure that describe my fuzzy system and I'm gonna to use it on MATLAB Simulink in general for fuzzy type 1 i could use fuzzy logic controller block BUT i have fuzzy type 2 and a structure describe it's membership functions and other attribute, i have to use it on simulink but matlab function block in simulink can't generate code for a cell array and i receive error.
so i ask you guys please help me:
is it possible to use cell array in matlab function block in simulink?
The MATLAB Function block supports all the data types that Simulink supports, see Data Types Supported by Simulink, and so I believe cell arrays aren't supported. However, you should be able to use the Fuzzy Logic Controller from the Fuzzy Logic Toolbox.

How to minimize multivariate function in Matlab by using derivatives?

How to minimize multivariate function in Matlab by using derivatives?
So far, for minimizing single variable functions I used fminunc,
but now I need to work with multivariate functions.
Thank you
Use fminunc. If you want to use the gradient, just return it as the 2nd output of your objective function. You'll also need to indicate in an options object that you are passing the gradient.
options = optimoptions('fminunc','GradObj','on');
I believe the documentation has info on passing the Hessian (if one exists).

How can I call an m file in Simulink and put it to a block in my model?

How can I call an m file in Simulink and put it to a block in my model (without using an S function)? Does anybody have an idea? I'd really appreciate it.
If you're trying to apply a user-defined MATLAB function to Simulink signals, there are a few different ways to do this, depending on your objective. All options are available within the User-Defined Functions section of the Simulink library.
Use the MATLAB function block if you intend to generate code from your model. This block does have restrictions, the entire gamut of built-in MATLAB functions is not available.
Use the Interpreted MATLAB function block if you don't care about code generation, this block can make use of any functions.
Use the Fcn block if your m-file is trivial and contains a simple expression operating on the inputs. In this case you can type the expression directly into the block dialog and reference the input / output signals as shown in the documentation.
MATLAB Fcn block is the best solution to embed M-function file into Simulink model. However, be cautious which version of MATLAB you are using, e.g., with later versions of MATLAB Function Block can be implemented with M-function file with %#codegen and C compiler need to be with your MATLAB package. Good luck