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

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

태그

질문:

2020년 12월 23일

댓글:

2020년 12월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by