Newbie question - Error in line 2

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

2 comentarios

Star Strider
Star Strider el 20 de Feb. de 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
Jim Riggs el 21 de Feb. de 2018
I see an error. See my comment, below.

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 20 de Feb. de 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 comentarios

Jonas Persson
Jonas Persson el 20 de Feb. de 2018
Thanks! When i try that the following happens:
Walter Roberson
Walter Roberson el 20 de Feb. de 2018
That line does not go into the file. You need to enter that at the command prompt.
Jonas Persson
Jonas Persson el 20 de Feb. de 2018
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.

Iniciar sesión para comentar.

Jim Riggs
Jim Riggs el 21 de Feb. de 2018
Editada: Jim Riggs el 21 de Feb. de 2018
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];

Categorías

Más información sobre MATLAB Report Generator en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 20 de Feb. de 2018

Editada:

el 21 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by