필터 지우기
필터 지우기

How to find zero on plot?

조회 수: 15 (최근 30일)
Mitul Dattani
Mitul Dattani 2018년 1월 8일
댓글: Star Strider 2018년 1월 8일
I have the code:
function [out] = iteration(N)
if N<0
error('less than 0');
end
x(1)=1;
for k=1:N-1
x(k+1) = exp(-sin(x(k)));
end
fprintf('Iteration given: '), x;
f = @(x) exp(-sin(x)) - x;
fplot(f, [0, pi]);
title('Searching for zero');
xz=fzero(fun,1);
out=x;
end
I need to find and display the zero values using xz=fzero(fun,1). How would I go about this been stuck here for a while now.

채택된 답변

Star Strider
Star Strider 2018년 1월 8일
When I plotted your function, there is only one zero. I would plot it as:
f = @(x) exp(-sin(x)) - x;
xz=fzero(f,1);
figure(1)
fplot(f, [0, pi])
hold on
plot(xz, 0, '+r')
hold off
  댓글 수: 2
Mitul Dattani
Mitul Dattani 2018년 1월 8일
the question wants me to use fzero to find it and show it
Star Strider
Star Strider 2018년 1월 8일
The code in my Answer does just that!
Run it to see.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by