Newbie question - Error in line 2

Sorry to ask a really newbie question. Does anyone know why the attached does not work?

댓글 수: 2

Star Strider
Star Strider 2018년 2월 20일
It appears that you are coding your own rotation matrix. I do not see any obvious errors.
I cannot run an image of your code, only posted and properly formatted code, so I cannot test it.
How are you calling it?
What about it is not working?
Jim Riggs
Jim Riggs 2018년 2월 21일
I see an error. See my comment, below.

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

답변 (2개)

Walter Roberson
Walter Roberson 2018년 2월 20일

0 개 추천

The error message itself did not get included, but I suspect that you tried to click Run to run the code. You need to save the file and then invoke the code from the command line, providing a value for the argument. For example,
AbvMa(pi/7)

댓글 수: 4

Jonas Persson
Jonas Persson 2018년 2월 20일
Thanks! When i try that the following happens:
Walter Roberson
Walter Roberson 2018년 2월 20일
That line does not go into the file. You need to enter that at the command prompt.
Jonas Persson
Jonas Persson 2018년 2월 20일
I am extremely grateful for the answer and sorry for being such a newbie. Could you help me with the syntax? I will not ask any more after that..
Get rid of the line
>> y = AbvMa(pi/7)
from your m-file, and call that from the command line.
y = AbvMa(pi/7)
Or else put it at the very top of the m-file, above the function line.

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

Jim Riggs
Jim Riggs 2018년 2월 21일
편집: Jim Riggs 2018년 2월 21일

0 개 추천

Your equation set looks like it produces a direction cosine matrix for a planar rotation about the Z axis. If this is the case, your notation is rather confusing, and there is a sign error in one of the terms. Your solution
y = [x1 x2 -x3; y1 y2 y3; x3 y3 z3]
gives the following matrix:
cos(v) sin(v) 0
sin(v) cos(v) 0
0 0 1
Note that you have put a minus sign on a term x3, which is zero. If you desire to construct a direction cosine matrix for a z-axis rotation, one of the sin(v) terms should be negated (depending on the direction of the rotation)
It would be much more clear (and concise) to build your function something like the following;
sinv=sin(v);
cosv=cos(v);
y = [cosv -sinv 0; sinv cosv 0; 0 0 1];

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2018년 2월 20일

편집:

2018년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by