Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

I get an error in the for loop.

1 visualizzazione (ultimi 30 giorni)
Muhendisleksi
Muhendisleksi il 3 Mag 2017
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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

Risposte (1)

Geoff Hayes
Geoff Hayes il 3 Mag 2017
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.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by