error in matlab function

조회 수: 1 (최근 30일)
studentU
studentU 2015년 5월 12일
댓글: Walter Roberson 2015년 5월 13일
hello,
I have a problem in matlab function block, where I use the trigonometric function, conversion function (ex:degtorad..) ... when I simulates a first part it works, but once I pass execter:
x = degtorad (var);
s = cos (x) * 2
... that it generated this error :
Expected Either a logical, char, int, fi, single, double gold. Found a MATLAB type. MATLAB kinds 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 have arguments to MATLAB calls.
can u help me?

답변 (3개)

Walter Roberson
Walter Roberson 2015년 5월 12일
Try
cx = cos(x);
s = cx * 2;

studentU
studentU 2015년 5월 12일
편집: Walter Roberson 2015년 5월 12일
thank's for your reply,
it solves some but for:
f = cos (var) * sin (var) * cos (arg) + sin (var) * cos (arg);
I proceed in the same manner: vc = cos (var) .. then F1=vc*vs*ca;.. and f = F1 + F2;
but it generates mismatch Size!!
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 5월 12일
You probably need to use .* instead of *
F1 = vc .* vs .* ca;

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


studentU
studentU 2015년 5월 12일
yes I used it but it does not solve the problem :/
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 5월 13일
Your var and your arg are not the same size and your arg is not scalar.
You need to define what size of output you want for that case.
Code would help.
Note: do not go down to "Answer this question" to reply. Click in "Comment on this Answer" instead.

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

카테고리

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