Accessing struct variable data inside MATLAB function block in Simulink
Show older comments
In MATLAB, I've been successfully using a custom matlab function that pulls data from a (complicated?) struct variable. The struct variable is one of the inputs in the function call. This struct variable is a 1x21 struct with 48 fields. The fields include strings, 1x1 doubles, nxm double arrays, griddedInterpolant classes. Note that all values in the struct are constants and are used for lookups and calculations.
I'm trying to recreate this same function in Simulink using the MATLAB function block. I'm at a loss to how I get the block to access the struct variable, which is in my workspace. I think the difficulty may come from the fact the struct has a bunch of different classes. I've tried having an input port on the function block that gets the data from a From File Block. I've tried a global variable, and I've tried loading the data inside the MATLAB function block. None of these seem to work.
Any suggestions on how I can get the data stored in this struct variable accessible inside the Simulink MATLAB function block? Thank you.
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!