Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I get an error in the for loop.

조회 수: 2 (최근 30일)
Muhendisleksi
Muhendisleksi 2017년 5월 3일
마감: MATLAB Answer Bot 2021년 8월 20일
DNdog =
7
11
BNdog =
4
4
nokta_ad =
4
7
11
dog_olc=
229.897
266.878
K =
3710709.539 3084028.627 4157648.644
3710479.640 3084171.030 4157677.581
3710442.600 3084257.800 4157623.100
for i = 1:3*length(DNdog)
l{i} = -((K(nokta_ad==BNdog{i},1)-K(nokta_ad==DNdog{i},1) - (dog_olc(nokta_ad==nokta_ad{i},1))))*100
end
Here is the error:
Cell contents reference from a non-cell array object.
Error in GPS_aglarinin_dengelenmesi (line 54)
l{i} = -((K(nokta_ad==BNdog{i},1)-K(nokta_ad==DNdog{i},1) - (dog_olc(nokta_ad==nokta_ad{i},3))))*100

답변 (1개)

Geoff Hayes
Geoff Hayes 2017년 5월 3일
Muhendisleksi - since your arrays seem to concern only numeric data, then they might not be cell arrays which use the curly braces {} to access elements within. For non-cell arrays, you need to use () to access the elements
l(i) = -((K(nokta_ad==BNdog(i),1)-K(nokta_ad==DNdog(i),1) - (dog_olc(nokta_ad==nokta_ad(i),3))))*100
Please confirm that the arrays are non-cell arrays before trying to use the above code. Also, you may want to consider pre-sizing the l array before adding elements to it.
Check your code too - look at the for loop
for i = 1:3*length(DNdog)
i ranges from 1 to three times the length of DNdog. This will be a problem with
DNdog{i}
when i is greater than length(DNdog) as you will be trying to access elements from this array with an index that is greater than the array size.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by