Loop does not work
Ältere Kommentare anzeigen
format long
tolerance = 10^-15;
y=0.1;
h=[y,y/2,y/4,y/8,y/16];
x=0;
I = (exp(x+h)-exp(x))./h;
z = length(h);
for n = 1:z-1 ;
while m < z-n
I(m) = (4/3) * I(m+1) - (1/3) * I(m);
m = m+1;
end
end
I
This is the code and i expected that the I matrix should go into the loop several times and as a result I should see 1x1 matrix but the loop stops after first iteration. What could be the problem?
3 Kommentare
Dyuman Joshi
am 30 Dez. 2023
m is not defined in the code above.
Please specify
> why I should be 1x1.
> what is the objective here / what you are trying to do.
Torsten
am 31 Dez. 2023
If I is a matrix, then why do you work with it as a vector ?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!