필터 지우기
필터 지우기

matlab coder error

조회 수: 1 (최근 30일)
ECE09 ITBHU
ECE09 ITBHU 2011년 8월 6일
i tried to convert a function from matlab to c. the function,s part accounting for error is:_
>> a=input('code no');
if (a == 1)
disp(' '); >>
the error in code generation report screen reads:-
Expected either a logical, char, int, fi, single, or double. Found a MATLAB type. MATLAB types are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may only be used on the right-hand side of assignments and as arguments to MATLAB calls.
how to avoid such error while convertion.

채택된 답변

Walter Roberson
Walter Roberson 2011년 8월 6일
input() evaluates what the user enters and so could return any arbitrary MATLAB type.
Possibly you might need to input a string and convert the string to a number.

추가 답변 (1개)

Kaustubha Govind
Kaustubha Govind 2011년 8월 6일
The error is occurring because you are calling an extrinsic function (input) that is not support for code generation. Therefore, the MATLAB Coder does not know what the expected return type is. See Working with mxArrays for more explanation. The solution in these cases is to pre-allocate 'a' so MATLAB Coder knows what type to expect. For example, use:
a=0; %specify size and type
a=input('code no');
if (a == 1)
disp(' ');
end

카테고리

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