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

 Réponse acceptée

Walter Roberson
Walter Roberson le 23 Déc 2020

0 votes

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 commentaires

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 le 23 Déc 2020
Your * operations should be .* operations
Aykhan Musazade
Aykhan Musazade le 23 Déc 2020
thank you very much sir
Walter Roberson
Walter Roberson le 25 Déc 2020
Nice try with the Rick Roll, but I didn't fall for it ;-)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2020a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by