Effacer les filtres
Effacer les filtres

Index in position 1 is invalid. Array indices must be positive integers or logical values Error

22 vues (au cours des 30 derniers jours)
GAIA QUARANTA
GAIA QUARANTA le 15 Juil 2024 à 20:43
Modifié(e) : Walter Roberson le 15 Juil 2024 à 21:03
Pdata=0:floor(length(pressure01)/400);
for i=0:length(pressure01)
for j=0:floor(length(pressure01)/400)
if mod(i,400)==0;
Pdata(j)=pressure01(i,1);
end
end
end
Im trying to get the code to work but it gives me an error in line 5 saying
Index in position 1 is invalid. Array indices must be
positive integers or logical values.
pressure01 is a column vector, not sure whats wrong

Réponses (1)

Torsten
Torsten le 15 Juil 2024 à 20:48
Déplacé(e) : Torsten le 15 Juil 2024 à 20:48
Array indexing in MATLAB starts with 1, not with 0. But you try to set
Pdata(0)=pressure01(0,1);
in your nested loop for i = 0 and j = 0 (so just at the start).

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by