Hello
nu=42
roll=-0.01-0.002*nu
pitch=0.01+0.002*nu
yawn=0.005+0.002*nu
Wx=0.0002+0.0001*nu
Wy=0.0003+0.0001*nu
Wz=0.0004+0.0001*nu
i have to loop nu 42 times and each time roll,pitch yawn, wx wy wz should change. Basically there should be 42 of each of them.I tried foor loop but it didnt work
max_nu = 42;
double roll[max_nu];
double pitch[max_nu];
double yawn[max_nu];
double Wx[max_nu];
double Wy[max_nu];
double Wz[max_nu];
for nu = 1; nu <= max_nu; nu=nu+1;
roll=-0.01-0.002*nu;
pitch=0.01+0.002*nu;
yawn=0.005+0.002*nu;
Wx=0.0002+0.0001*nu;
Wy=0.0003+0.0001*nu;
Wz=0.0004+0.0001*nu;
end

 Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Dic. de 2020
No loop needed
nu = 1 : max_nu;
roll=-0.01-0.002*nu;
pitch=0.01+0.002*nu;
yawn=0.005+0.002*nu;
Wx=0.0002+0.0001*nu;
Wy=0.0003+0.0001*nu;
Wz=0.0004+0.0001*nu;

4 comentarios

Thanks it worked but now i get marix size error when running full code
max_nu=42;
nu = 1 : max_nu;
roll=-0.01-0.002*nu
pitch=0.01+0.002*nu
yawn=0.005+0.002*nu
Wx=0.0002+0.0001*nu
Wy=0.0003+0.0001*nu
Wz=0.0004+0.0001*nu
Jx=2.1*10^(-3)
Jy=2*10^(-3)
Jz=1.9*10^(-3)
W=0.0011
Nt=3.6*10^(-10)
N=54000
deltaT=0.1
rick=roll+deltaT*((Wy*sin(roll)-Wz*cos(roll))*tan(pitch)+Wx)
pawn=pitch+deltaT*(Wy*cos(roll)-Wz*sin(roll)+W)
yummy=yawn+deltaT*(Wy*sin(roll)+Wz*cos(roll))*sec(pitch)
wix=Wx+(deltaT/Jx)*(Jy-Jz)*Wz*Wy+(deltaT/Jx)*Nt
wiy=Wy+(deltaT/Jy)*(Jz-Jx)*Wx*Wz+(deltaT/Jy)*Nt
wiz=Wz+(deltaT/Jz)*(Jx-Jy)*Wx*Wy+(deltaT/Jz)*Nt
plot(rick)
Walter Roberson
Walter Roberson el 23 de Dic. de 2020
Your * operations should be .* operations
Aykhan Musazade
Aykhan Musazade el 23 de Dic. de 2020
thank you very much sir
Walter Roberson
Walter Roberson el 25 de Dic. de 2020
Nice try with the Rick Roll, but I didn't fall for it ;-)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Versión

R2020a

Etiquetas

Preguntada:

el 23 de Dic. de 2020

Comentada:

el 25 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by