How to select specific points/intersections in a matlab plot?
이전 댓글 표시
I'm solving numerical analysis problems in which I need to find the the zeroes of certain equations with an error of less than 10^-2.
With the following code:
clc
format long
x = linspace(-1, 3, 1000);
y = ( abs( log(x + 1) ) -2 + x );
plot(x,y)
hold on
plot(x,0,'b')
I've managed to create two intersecting graphs as such:
What I want, though, is for Matlab to highlight the points where the y = 0 line intersects my original graph. That way I can know when to stop using the "successive bissections" method.
답변 (1개)
madhan ravi
2019년 3월 16일
idx=(abs(y)<1e-2);
% ^^^^----- tolerance (10^-2)
plot(x(idx),zeros(1,nnz(idx)),'sqb')

댓글 수: 2
bobsoney bobsoney
2019년 3월 16일
madhan ravi
2019년 3월 16일
x0 = fsolve(@(xx) abs( log(xx + 1) ) -2 + xx ,[-.99,3]); % solve for x when y = 0
plot(x0,zeros(1,numel(x0)),'o','MarkerSize',10)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!