I am having a rather basic problem that I still cant figure it out.
I have two arrays: both have a 64x1 dimension but one is the result of a foor loop using angle as the index (alpha = 25:89). On the other hand the other array has been defined as follows (i = 1:64)
How can I multiply each variable of these arrays without getting the following error: Index in position 1 exceeds array bounds (must not exceed 64).

댓글 수: 4

Stephen23
Stephen23 2020년 10월 6일
"...one is the result of a foor loop using angle as the index (alpha = 25:89)"
That is the start of your problems: confusing data with code. This approach is fragile and inefficient. Any negative, zero, or fractional values will throw an error. Any "missing" angles (up to the maximum) will still have stored values in the data array, but serve no purpose.
A much more robust approach would be to store the angles in one vector and the results in another. Then all of your data vectors will have exactly the same size.
Marcelo Boldt
Marcelo Boldt 2020년 10월 6일
Very good I got the conccept right away, Thank you!
Walter Roberson
Walter Roberson 2020년 10월 6일
Search tag:"generalized for loop" for an description of how to proceed.
Marcelo Boldt
Marcelo Boldt 2020년 10월 6일
I did it and it worked, Thanks!

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

답변 (0개)

카테고리

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

질문:

2020년 10월 6일

댓글:

2020년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by