Attempt to extract field 'accel' from 'mxArray'
9 ビュー (過去 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 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!