Azzera filtri
Azzera filtri

Index error: must be logical or positive integer.

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Askic V
Askic V il 21 Feb 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.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by