MATLAB Answers

0

Is there any way to pass a cell, cfit object or function from the workspace into a matlab function block in simulink?

Asked by Alex Saoulis on 24 Apr 2019
Latest activity Commented on by Mark McBroom on 27 Apr 2019
I have tried a number of ways, all to little or no avail. At the moment I have a number of surfaces stored as cfit objects, which I would like to evaluate within a matlab function block in simulink. However, I can't find any way to pass these objects into the function from the workspace (it doesn't need to be from the workspace; is there any way to load an object within simulink or in the matlab function block such that the matlab function block can use the object?). I've been trying by changing the type of scope to parameter or data store memory. I have the cfit objects saved in a .mat file, and also in the workspace.
Things I have tried so far:
  • Convert the cfit object into a function and pass it as a function handle (parameter into the matlab func block)
  • Pass it as the object itself (parameter into the matlab func block)
  • Pass the .mat file as a Data store memory object
I've been struggling with this for a few days and honestly really surprised that I haven't been able to find any solution; it seems like it should be quite easy. The only method that I have been able to use to pass the info in the cfit object into the workspace is by using an interpreted matlab function block in simulink, and passing the cfit object as a function. Would there be any way to use this interpreted matlab function block within a matlab function block? I am grasping at straws here.

  1 Comment

What do you intend to do with the cfit object once in the MATLAB function Block? Since MATLAB Function Blocks are always converted to C code for simulation, you will have to limit yourself to MATLAB functions supported for code generation. Check section 3 here for the list of supported MATLAB functions.

Sign in to comment.

0 Answers