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