Newbie question - Error in line 2
Afficher commentaires plus anciens
Sorry to ask a really newbie question. Does anyone know why the attached does not work?
2 commentaires
Star Strider
le 20 Fév 2018
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
le 21 Fév 2018
I see an error. See my comment, below.
Réponses (2)
Walter Roberson
le 20 Fév 2018
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 commentaires
Jonas Persson
le 20 Fév 2018
Walter Roberson
le 20 Fév 2018
That line does not go into the file. You need to enter that at the command prompt.
Jonas Persson
le 20 Fév 2018
Image Analyst
le 20 Fév 2018
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];
Catégories
En savoir plus sur MATLAB Report Generator dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!