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

 採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 23 日

0 投票

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 件のコメント

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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

製品

リリース

R2020a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by