MATLAB Answers

Info

This question is closed. Reopen it to edit or answer.

A for loop need help ASAP

1 view (last 30 days)
Nikolaos Zafirakis
Nikolaos Zafirakis on 30 Apr 2019
Closed: Stephen Cobeldick on 30 Apr 2019
I have a loop and I want to collect the output?
A are arrays 0:300
for i = 0:3:300
Fi = atan(-(A5(1,1+i)/A5(1,2+i)));
Theta = acos(A5(1,3+i));
Psi = atan(A3(1,3+1)/A4(1,3+i));
end

Answers (1)

Torsten
Torsten on 30 Apr 2019
Edited: Torsten on 30 Apr 2019
for i = 0:3:300
j = i/3 + 1;
Fi(j)= atan(-(A5(1,1+i)/A5(1,2+i)));
Theta(j) = acos(A5(1,3+i));
Psi(j)= atan(A3(1,3+i)/A4(1,3+i));
end

  2 Comments

Nikolaos Zafirakis
Nikolaos Zafirakis on 30 Apr 2019
Thanks for the reply, but it errors and says array indices must be positive integers or logical values!
Torsten
Torsten on 30 Apr 2019
j = 0;
for i = 0:3:300
j = j + 1;
Fi(j)= atan(-(A5(1,1+i)/A5(1,2+i)));
Theta(j) = acos(A5(1,3+i));
Psi(j)= atan(A3(1,3+i)/A4(1,3+i));
end