Plot problem: How to mark a symbol "X".

조회 수: 34 (최근 30일)
Phuc Tan Huynh
Phuc Tan Huynh 2016년 5월 6일
편집: Star Strider 2016년 5월 7일
I had a question to plot two function on a graph, and for each intersection point of two function, mark a symbol "X". I don't know how to do it, Please help me.

답변 (1개)

Star Strider
Star Strider 2016년 5월 6일
If you have calculated the intersection as a (xi,yi) pair, use the hold command, and then:
plot(xi, yi, 'x')
  댓글 수: 2
Phuc Tan Huynh
Phuc Tan Huynh 2016년 5월 6일
Oh well, thanks for your help but it is still confused for me. I already use fzero to find these intersection points of these two function and displayed these out. So how can I declare xi and yi like you said ???
Star Strider
Star Strider 2016년 5월 6일
편집: Star Strider 2016년 5월 7일
My pleasure.
I would have to see your code.
However, if you used fzero, you probably have the ‘xi’ coordinates, and since fzero requires a function that most likely subtracts one function from another, you would use that value in one of the functions you used to calculate ‘xi’ to calulate ‘yi’.
Example:
f1 = @(x) 10 - 5*x;
f2 = @(x) x.^2 + 1;
xi = fzero(@(x) f1(x)-f2(x), 1);
t = linspace(0, 3);
figure(1)
plot(t, f1(t), '-b', t, f2(t), '-g')
hold on
plot(xi, f1(xi), 'xr', 'MarkerSize',20)
hold off
grid

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by