How to use three- line loop with disp to find derivative
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dhurgham Kadhim
am 12 Feb. 2012
Bearbeitet: Matt J
am 12 Okt. 2013
I want to find the first five derivatives of f(x)=x((2x+1)^1/2), Using the three-line for loop wih disp.
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 12 Feb. 2012
syms x real
f = x.*(2*x+1).^(1/2)
df = arrayfun(@(i1)diff(f,x,i1),1:5,'un',0);
out = cat(1,df{:})
:)
out = sym('out',[5, 1]);
x = sym('x');
for i1 = 1:5
out(i1) = diff(x.*(2*x+1).^(1/2),x,i1);
end
Weitere Antworten (2)
Jan
am 13 Feb. 2012
You cannot find the derivative using a FOR-loop. As far as I can see, you only can use forward, backward or central differences to calculate an approximation of the derivative.
It is not clear what a "three-line for loop" is any what "with disp" exactly mean. It seems like you got a strange homework assignment.
0 Kommentare
Siehe auch
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!