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)

 Akzeptierte Antwort

Voss
Voss am 11 Feb. 2022
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 Kommentare

Andrew Maxey
Andrew Maxey am 11 Feb. 2022
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.?
Andrew Maxey
Andrew Maxey am 11 Feb. 2022
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
Andrew Maxey
Andrew Maxey am 11 Feb. 2022
Your answer to my question was correct, I realized I called for the function before defining it.
Voss
Voss am 11 Feb. 2022
Glad you got it to work!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Gefragt:

am 11 Feb. 2022

Kommentiert:

am 11 Feb. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by