how to calculate a difference of function with any parameter
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
shiv gaur
am 8 Jan. 2022
Kommentiert: shiv gaur
am 8 Jan. 2022
function y=f(x)
for i=10
y=i*sin(x)
end
end
calculate the change in y/change in x vs i
0 Kommentare
Akzeptierte Antwort
Torsten
am 8 Jan. 2022
Bearbeitet: Torsten
am 8 Jan. 2022
function main
h = 1e-6;
xleft = -pi;
xright = pi;
n = 200;
dx = (xright-xleft)/n;
x = xleft:dx:xright;
change_in_y_by_change_in_x = (f(x+h)-f(x))/h;
plot(x,change_in_y_by_change_in_x)
hold on
plot(x,cos(x)) % for comparison, plot (sin(x))' = cos(x)
end
function y = f(x)
y = sin(x)
end
7 Kommentare
Torsten
am 8 Jan. 2022
Please include the function f in which you calculate "N" dependent on "da" callable as
N = f(da)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!