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!