F is giving me the same measurements and I can’t seem to find how to move to the next position.
A = (:,:,1) % There are 100 A symmetric matrix
for i = 1:100A
F(i) = atan(-(A(3,1)/A(3,2))) % Second A should be position (A(3,4).....
end

답변 (1개)

Stephan
Stephan 2019년 4월 30일
편집: Stephan 2019년 4월 30일

0 개 추천

Hi,
it is not recommended to use i - since i is reserved for complex numbers. Perhaps use k or n or ii instead. I decided to use ii:
The idea is to work with the counter variable ii in this context. That means you have to find a way to express the steps of the loop by your counter variable. For example:
for ii = 1:99
F(ii) = atan(-(A(3,ii)/A(3,ii+1)))
end
would make the pairs:
ii = 1 --> A(3,1) / A(3,2)
ii = 2 --> A(3,2) / A(3,3)
ii = 3 --> A(3,3) / A(3,4)
...
ii = 99 --> A(3,99 / A(3,100)
I leave it to you to find an expression that counts the way you need it.
Best regards
Stephan

댓글 수: 6

Nikolaos Zafirakis
Nikolaos Zafirakis 2019년 4월 30일
Hello Stephan,
To be honest with you I know how the indexing already works. My problem is more in the counter because I have 100 matrix and i need my loop to take one matrix in at a time do you have any advice for this? Thanks for your reply!
kind regards,
Nik
madhan ravi
madhan ravi 2019년 4월 30일
Preallocation is essential.
Stephan
Stephan 2019년 4월 30일
This takes first and second Matrix from A, then second and third and writes the results in the preallocated F Array:
A = randi(10,3,3,3)
F = nan(3,3,2)
for ii = 1:size(A,3)-1
F(:,:,ii) = atan(-(A(:,:,ii)/A(:,:,ii+1)))
end
Nikolaos Zafirakis
Nikolaos Zafirakis 2019년 4월 30일
I have a loop and I want to collect the output? the answer you give me does not satisfy the output as I need to keep all the A the way they are any suggestions?
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
I'm not certain I understand what you're trying to compute. Can you show us exactly what the results should be for the following A vector?
A = 1:9;
Stephan
Stephan 2019년 4월 30일
I agree - we would need a example to be sure understanding you correctly

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2019년 4월 30일

댓글:

2019년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by