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
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
2018 年 2 月 21 日
I see an error. See my comment, below.
回答 (2 件)
Walter Roberson
2018 年 2 月 20 日
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
2018 年 2 月 20 日
Walter Roberson
2018 年 2 月 20 日
That line does not go into the file. You need to enter that at the command prompt.
Jonas Persson
2018 年 2 月 20 日
Image Analyst
2018 年 2 月 20 日
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.
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 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!