Code to input function
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to make a code where user can input the the function and as the output they get plot of f(x) vs x and also the roots of that non linear equation.
0 Kommentare
Antworten (2)
David Hill
am 29 Aug. 2022
Plotting would not be a problem, but finding all the roots is a problem. Recommend looking at fzero
a=input('Function (example: @(x)x.*cos(x)-x.^2.*sin(x)+exp(-x)): ','s');
f=str2func(a);
x=-pi:.001:2*pi;
plot(x,f(x));
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB 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!