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

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

Accepted Answer

Stephen23
Stephen23 on 24 Apr 2023
Edited: Stephen23 on 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

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!