cell array is not supported for my hdl coder in matlab,, how to fix it - matlab-deployment

while converting my .m file in matlab to vhdl using hdl coder iam getting cell array is not supported . How to fix these errors while fixed point conversion

As you wrote, cell arrays are not supported as input arguments or return values. This is a limitation in MATLAB codegen products such as MATLAB Coder and HDL Coder. You'll need to modify or wrap the function to use supported types. A commonly used option is to replace cell arrays with structures. See:
http://www.mathworks.com/matlabcentral/answers/63288-removing-cell-arrays-from-code

Related

Is it possible to use Matlab Coder to get a C version of an inbuilt Matlab filter design function?

I'm specifically looking at something like Matlab's firpm function (I know there are C implementations of Remez available online in several sources).
The firpm page on the MATLAB documentation, under "Extended Capabilities", says the function is compatible with C/C++ code generation with the MATLAB Coder.

cell array isn't supported by Matlab coder

I have a list of matrices. I want to use Matlab coder to get the corresponding c code and hence run the program faster. However, cell array is not supported in Matlab coder. Is there any other way to make a list of matrices so that Matlab coder supports the resulting list of matrices?

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.

RMS not supported in Matlab function inside Simulink

Simulink has a module called "Matlab Function," which allows you to create a custom function in a Simulink flow diagram.
I implemented a simple function in a Simulink Matlab Function module. My function contains a call to Matlab's built-in rms(). When I run the Simulink model, I get the following error:
The function 'rms' not supported for standalone code generation
If I remove rms from my Matlab Function in the Simulink model, the error goes away and the model runs flawlessly.
Questions:
Is there a way to use Matlab's rms in Simulink?
Are there many other native Matlab calls that can't be used inside Simulink?
I just wanted to clarify and expand upon some points made in learnvst's answer.
Even if you are simply trying to simulate a model containing a MATLAB Function block and are not explicitly attempting to perform code generation, you will still get the not supported for standalone code generation error.
As learnvst indicated, there are multiple restrictions on functions that can be used with code generation. However, if you just want to simulate your model, Simulink allows you to do this if you signify these "black-listed" functions as being extrinsic. This lets Simulink know that the functions will be used for simulation purposes only and won't be part of code generation.
In your particular case, add the following line of code somewhere before your call to rms:
coder.extrinsic('rms');
Declaring a function as extrinsic in a MATLAB Function is often useful even when you are performing code generation. For example, you may want to visualize your data using the plot command during simulation, but obviously would not need the plot command to be part of generated code.
Refer to this doc for more info on declaring functions to be extrinsic.
The not supported for standalone code generation part of the error suggests to me that you are trying to use a product like Matlab Coder to make an executable or native code. If this is the case, there are many naive calls that cannot be used directly in both core Matlab and the toolboxes. The coder products only support a subset of the language. More information can be found here . . .
http://www.mathworks.co.uk/products/matlab-coder/description2.html
As for your call to rms, it is only calculating the root of the mean of the squares. Try creating an alternative using something like . . .
sqrt(mean(x.^2))
...where x is the signal.

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