why the code is incorrect? and where is incorrect? Matlab told me the function is incorrect, why?

2 visualizzazioni (ultimi 30 giorni)
fun = 2*exp(-x)+sin(x); % function
x0 = [3 4]; % initial interval
x = fzero(fun,x0)

Risposta accettata

Stephen23
Stephen23 il 24 Apr 2023
Modificato: Stephen23 il 24 Apr 2023
"why the code is incorrect?"
FZERO expects its first input argument to be a function handle:
"and where is incorrect?"
You did not define a function handle, just like FZERO requires. I fixed that for you:
fun = @(x) 2*exp(-x)+sin(x);
% ^^^^ create anonymous function, FUN is its handle.
x0 = [3 4];
x = fzero(fun,x0)
x = 3.2215

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by