필터 지우기
필터 지우기

error in embedded matlab function

조회 수: 6 (최근 30일)
studentU
studentU 2015년 5월 20일
편집: Ryan Livingston 2015년 6월 2일
hi, how to resolve this type of error: Function output 'x'and 'y' cannot be of MATLAB type. where x&y are the output of my function, i use for their calculation, radtodeg()

답변 (3개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 5월 20일
편집: Azzi Abdelmalek 2015년 5월 20일
Some function are not supported for c code generation. You can tell Matlab that you do not need code generation for those functions by inserting in your function block
coder.extrinsic('radtodeg')
  댓글 수: 1
studentU
studentU 2015년 5월 20일
thank's for ur repply, yes, with the use of coder.extrinsic('radtodeg'), the error exist

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


Walter Roberson
Walter Roberson 2015년 5월 20일
When you call a MATLAB function in a MATLAB Function Block, you usually need to assign the result to a variable and then use the variable, instead of using the result in an expression. As a simple example,
y = abs(sin(x));
you might need to rewrite as
t = sin(x);
y = abs(t);
This does not have to do with whether the routine is supported for code generation: it is a restriction on how you can use the results of calling a MATLAB routine.
  댓글 수: 2
studentU
studentU 2015년 5월 20일
thank's Roberson for ur repply, i try this way but it not resolve the problem.
Ryan Livingston
Ryan Livingston 2015년 6월 2일
편집: Ryan Livingston 2015년 6월 2일
This answer isn't true in general. Results of function calls can typically be used in expressions in a MATLAB Function Block. Only in some cases when the function being called has been declared extrinsic, does the output need to be assigned to a variable whose datatype is known.

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


Ryan Livingston
Ryan Livingston 2015년 6월 2일
Since you've declared radtodeg as an extrinsic, its output needs to be pre-assigned to a value that tells Simulink what the output size, type, and complexity of radtodeg will be. So if radtodeg always returns an array of the same size as its input you could use:
y = u; % assign example of correct size, complexity, and type
y = radtodeg(u); % call extrinsic function

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by