how can I plot this point on my area subplot

I am trying to plot the maximum value onto my subplot
x=linspace(0,L,1000);
V= R.*(x>0).*(x-0).^0 - (w).*(x>a).*(x-a).^1 - F1.*(x>b).*(x-b).^0 + (w).*(x>c).*(x-c).^1 + R.*(x>L).*(x-L).^0;
subplot(4,2,1);
area(x,V);
ylabel('V_y (N)');
ylim([min([1.2*min(V),0,-1.2*min(V)]),max([0,1.2*max(V),-1.2*max(V)])]);
xlim([0,1.2*L])
[Vmax i]=max(V)
xmaxV=x(i)

 채택된 답변

Voss
Voss 2022년 2월 11일
I don't have your data, but one way to do it is to use hold on so both the area and the point are shown simultaneously, and put a marker on your point so you can see it:
L = 100;
x = linspace(0,L,1000);
V = 2500-(x-50).^2;
area(x,V);
[Vmax i]=max(V)
Vmax = 2.5000e+03
i = 500
xmaxV=x(i)
xmaxV = 49.9499
hold on
plot(xmaxV,Vmax,'o','MarkerFaceColor','r','MarkerSize',20)

댓글 수: 5

so i tried that, and when i do it gives me this
Unrecognized function or variable 'xmaxV'.
Error in ME466_2_quiz2 (line 40)
plot(xmaxV,Vmax,'o','MarkerFaceColor','r','MarkerSize',20)
What's the output to the command line when the previous two lines run?
[Vmax i]=max(V)
xmaxV=x(i)
Is there a typo somewhere, e.g., XmaxV or xmaXv, etc.?
I haven gone over it multiple times and cant find a typo, but this is the ouput it is giving me
Vmax =
1675
i =
2
xmaxV =
0.0010
Your answer to my question was correct, I realized I called for the function before defining it.
Voss
Voss 2022년 2월 11일
Glad you got it to work!

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

추가 답변 (0개)

카테고리

태그

질문:

2022년 2월 11일

댓글:

2022년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by