フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I get an error in the for loop.

1 回表示 (過去 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