Attempt to extract field 'accel' from 'mxArray'
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!