Filter löschen
Filter löschen

Index error: must be logical or positive integer.

1 Ansicht (letzte 30 Tage)
Muhammad Amir Javed
Muhammad Amir Javed am 21 Feb. 2023
Kommentiert: DGM am 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;
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.

Akzeptierte Antwort

Askic V
Askic V am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by