How do I plot a point on a graph?

I want to plot my tau max on my Mohr's Circle graph which I was thinking was plot(C,R) but I am not getting any results. I also want it to display the value on the graph which should be 612.11
sigx=-30.90;
sigy=51.06;
tauxy=-610.74;
R=sqrt(((sigx-sigy)/2)^2+tauxy^2)
C=(sigx+sigy)/2
sig1=C+R
sig2=C-R
sigma=linspace(sig2,sig1,1000);
tau1=sqrt(R^2-(sigma-C).^2);
tau2=-tau1;
plot(sigma,tau1,'b',sigma,tau2,'b')
title('Mohrs Circle (1672.13 lbs)')
xlabel('\sigma(psi)')
ylabel('\tau(psi)')
axis('square')
hold on
plot([sig1,sig2],[0,0],'k')
plot([sigx,sigy],[-tauxy,tauxy],'g')
grid on;

답변 (1개)

Robert Brown
Robert Brown 2021년 4월 18일
편집: Robert Brown 2021년 4월 18일

2 개 추천

Add these lines to the bottom of your code, to plot the desired value as a red asterisk on the existing plot with the other data plotted. Then reference the plot handle "p_include", from a legend request, to get a legend with only this plot data value included. string( R) converts R to a string and assigns it as a name for the plot which plots it on the figure.
p_include = plot(C,R,'r*','DisplayName',string(R))
legend(p_include)
chances are, your added plot of C,R was being plotted as a tiny line segment, but you just couldn't see it on your plot since it only had 1 data point.
The red asterisk will make the data point show up more clearly on your plot, and the legend will contain the numerical value R of the max value
I hope this helps ! :-)

댓글 수: 3

Erick Santiago
Erick Santiago 2021년 4월 18일
Yup that's what it was. Now how can I get it to display on that same graph the value? For example, have it say R=612.11 on the graph
Robert Brown
Robert Brown 2021년 4월 18일
check update in original answer above...
Robert Brown
Robert Brown 2021년 4월 18일
PS if my answer helped, please vote for it :-)
Just click on the little "vote" tag by my answer

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

카테고리

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

제품

질문:

2021년 4월 18일

댓글:

2021년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by