Effacer les filtres
Effacer les filtres

Index error: must be logical or positive integer.

1 vue (au cours des 30 derniers jours)
Muhammad Amir Javed
Muhammad Amir Javed le 21 Fév 2023
Commenté : DGM le 21 Fév 2023
T=10:2:60;
f=-1:length(T)+1;
total=-1;
i=f+total;
et=3.5e-4;
dn1=1e-9:100e-9;
if i==0
r=0;
else
% r=(et+((dn1(i+1)-dn1(i))))./((dn1(i)-(dn1(i-1)))+et); upwind and lower
% wind
r=(et+((dn1(i+1)-dn1(i))))./((dn1(i)-(dn1(i-1)))+et);
end
Array indices must be positive integers or logical values.
  1 commentaire
DGM
DGM le 21 Fév 2023
Is i a positive integer or logical value?

Connectez-vous pour commenter.

Réponse acceptée

Askic V
Askic V le 21 Fév 2023
T=10:2:60;
f=-1:length(T)+1;
total=-1;
i=f+total;
et=3.5e-4;
dn1=1e-9:100e-9;
size(dn1)
ans = 1×2
1 1
size(i)
ans = 1×2
1 29
if i==0
r=0;
else
% r=(et+((dn1(i+1)-dn1(i))))./((dn1(i)-(dn1(i-1)))+et); upwind and lower
% wind
r=(et+((dn1(i+1)-dn1(i))))./((dn1(i)-(dn1(i-1)))+et);
end
Array indices must be positive integers or logical values.
I hope you can see where the error is.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by