Attempt to extract field 'accel' from 'mxArray'
9 views (last 30 days)
Show older comments
I am trying to build a self contained function block in Simulink that will be compiled into a standalone executable that accepts a parameter input. This parameter input will be used to generate a string representing a filename (a .mat file). This .mat file will be loaded using load(filename). Here is the code: {
function result = fcn(filename)
coder.extrinsic('num2str');
coder.extrinsic('strcat');
cursimfile = strcat(num2str(filename),'.mat');
accelstruct = load(cursimfile);
accel = accelstruct.accel; %%The mat file has a field called accel which is a 2 x n array
result = someotherfunction(accel);
On the line accel=accelstruct.accel, I am getting an error 'Attempt to extract field 'accel' from 'mxArray''. My problem is that the usual solution of declaring the accel variable as a 2 x n array requires me to know the n value. I can obtain the n value by doing length(accelstruct.accel). But even this line gives me the same error. Every .mat file that I will pass to this compiled code will be of different length (n).
Any suggestions on how to get over this?
0 Comments
Answers (0)
See Also
Categories
Find more on MATLAB Compiler 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!