drawing a point in the graph

답변 (2개)

Arif Hoq
Arif Hoq 2022년 12월 6일
편집: Arif Hoq 2022년 12월 6일

0 개 추천

x = 1:5;
y = 20:24;
plot(x,y,x(3),y(3),'*') % specify a marker symbol * in index 3 of y
please follow this for more information about plot

댓글 수: 3

thank you. How can I mark the point of intersection in the following case?
"
t1 = 0:0.5:2;
x1 = t1/2-1;
t2 = 2:0.5:20;
x2 = t2 - sqrt(2*t2);
t3 = 0:0.5:1;
x3 = t3+1;
t4 = 1:0.5:11.6;
x4 = 2*sqrt(t4);
figure(1)
plot(x1, t1, 'b', x2, t2, 'r', x3, t3, 'k', x4, t4, 'g')
"
try this approach. I am not sure about his efficiency.
t1 = 0:0.5:2;
x1 = t1/2-1;
t2 = 2:0.5:20;
x2 = t2 - sqrt(2*t2);
t3 = 0:0.5:1;
x3 = t3+1;
t4 = 1:0.5:11.6;
x4 = 2*sqrt(t4);
figure(1)
[x1equality ia]=find(ismember(t1,t2));
[x3equality ib]=find(ismember(t3,t4));
plot(x1, t1, 'b', x2, t2, 'r', x3, t3, 'k', x4, t4, 'g',x1(ia),t1(ia),'*',x3(ib),t3(ib),'*')
Ismita
Ismita 2022년 12월 7일
Thank you :)

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

Walter Roberson
Walter Roberson 2022년 12월 6일

0 개 추천

x = 0:0.5:10;
t = (x/2).^2;
abs(x-2*sqrt(t)) %cross-check weether x == 2*sqrt(t)
ans = 1×21
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
plot(x, t, '*-')

댓글 수: 5

Ismita
Ismita 2022년 12월 6일
편집: Walter Roberson 2022년 12월 6일
thank you. How can I mark the point of intersection in the following case? TIA
t1 = 0:0.5:2;
x1 = t1/2-1;
t2 = 2:0.5:20;
x2 = t2 - sqrt(2*t2);
t3 = 0:0.5:1;
x3 = t3+1;
t4 = 1:0.5:11.6;
x4 = 2*sqrt(t4);
figure(1)
plot(x1, t1, 'b', x2, t2, 'r', x3, t3, 'k', x4, t4, 'g')
You need to calculate the point of interesection between (x2,t2) and (x4,t4) . Then you can plot() that point, specifying a marker. For example,
plot(interesection_x, intersection_y, 'b*')
Ismita
Ismita 2022년 12월 7일
Problem is, the point of intersection is only one point but the x and t limits are not from the same region (x1, x2, x3, x4 and corresponding t1, t2, t3, t4) plot. The intersection is x4==6.78233, t2==11.66
plot(x4==6.78233, t2==11.66,'r*') does not work
plot(6.78233, 11.66, 'r*')
It does not matter if there is no exact match for this in the curves, if it is the correct intersection point.
Unless, that is, what you want to do is find the closest point on each of the two curves and mark those close points rather than the intersection point?
Ismita
Ismita 2022년 12월 7일
thank you :)

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

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

질문:

2022년 12월 6일

댓글:

2022년 12월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by