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

 Risposta accettata

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 Commenti

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)
Your * operations should be .* operations
thank you very much sir
Nice try with the Rick Roll, but I didn't fall for it ;-)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Prodotti

Release

R2020a

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by