------ I have a problem with this code. The code run for Matlab2011 and I have 2014a. It was typed from Matlab book, so the code is right... and This is de code:
function RHz=HRz(theta)
dato=whos('theta');
if strcmp(dato.class','sym')
RHz=[cos(theta), -sin(theta), 0,0;
sin(theta), cos(theta), 0,0;
0,0,1,0;
0,0,0,1];
else digits(3);
RHz=round([vpa(cos(theta),3), vpa(-sin(theta),3),0,0;
vpa(sin(theta),3), vpa(cos(theta),3),0,0;
0,0,1,0;
0,0,0,1]);
end
---------------------Error is:
Error using strcmp
Not enough input arguments.
Error in HRz (line 3)
if strcmp(dato.class,'sym')

댓글 수: 4

Gizeh - perhaps you have another function named strcmp which is conflicting with the expected MATLAB one. In the command line, type
which strcmp -all
to see where this function has been defined.
Guillaume
Guillaume 2018년 11월 22일
편집: Guillaume 2018년 11월 22일
The line of code in the error message does not match exactly the line of code in the given function. The function has an extra ' after dato.class that the error message doesn't show. Which of the two (if any) shows the actual code?
Note that there is no need to go the roundabout way to get the class of theta, the following would be simpler:
function RHz=HRz(theta)
if strcmp(class(theta), 'sym')
%... rest of the code as it is
It won't result the problem with strcmp which should not raise the error you give unless you have indeed shadowed it with you own version as per Geoff's comment.
isa(theta, 'sym')
madhan ravi
madhan ravi 2018년 11월 23일
+1 sir Walter

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2018년 11월 23일
편집: Cris LaPierre 2018년 11월 23일

0 개 추천

The error message suggest dato.class is empty. The trailing ' is not going to help the comparison, but when dato.class has a value, that alone doesn't generate an error message.
What are you passing into the function as theta? The only way I get this error message with this setup is if theta does not exist.

카테고리

도움말 센터File Exchange에서 Get Started with Phased Array System Toolbox에 대해 자세히 알아보기

질문:

2018년 11월 22일

댓글:

2018년 11월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by