why the code is incorrect? and where is incorrect? Matlab told me the function is incorrect, why?
2 views (last 30 days)
Show older comments
fun = 2*exp(-x)+sin(x); % function
x0 = [3 4]; % initial interval
x = fzero(fun,x0)
0 Comments
Accepted Answer
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)
More Answers (0)
See Also
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!