필터 지우기
필터 지우기

Subscripting into an mxArray

조회 수: 35 (최근 30일)
ECE09 ITBHU
ECE09 ITBHU 2011년 8월 8일
댓글: gaoliming gao 2020년 5월 19일
given below is a part of the code i am writing for kalman filter but got error while converting from .m to .c/.c++
white_gauss=wgn(1,37000,20);
q1=cov(white_gauss);
q2=cov(white_gauss);
q3=cov(white_gauss);
loop_count=12;
L=loop_count;
Q=[q1(L) q2(L) q3(L)]
and got following error while converting from .m to .c using matlab coder.
"Subscripting into an mxArray is not supported. "
how to avoid it?

채택된 답변

Mike Hosea
Mike Hosea 2011년 8월 9일
That is the error you get when you use coder.extrinsic and fail to declare the output before calling the extrinsic function. If you only want to pass the output to extrinsic functions, you don't have to, but if you want to index into the result, you have to pre-define its size and type. For example, suppose foo(x) returns a result with the same size and type as x. Then you could write
y = x;
y = foo(x);
Or if foo always returns a 4-by-1 array of int32's, you would write
y = zeros(4,1,'int32');
y = foo(x);
This tells the compiler how to deconstruct the data structure that comes back from MATLAB when the function foo is called with x as input. -- Mike
  댓글 수: 5
zeng xiao
zeng xiao 2017년 4월 11일
您好哦,您的问题解决了吗?我也遇到了相同的问题,您可以顺便为我解答一下吗?
gaoliming gao
gaoliming gao 2020년 5월 19일
Initialize the variable before use it, for example y = zeros(4,1);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by