Highlight y-max

34 ビュー (過去 30 日間)
Benjamin Nienhouse
Benjamin Nienhouse 2020 年 11 月 18 日
コメント済み: Benjamin Nienhouse 2020 年 11 月 20 日
So I'm wondering how I would highlight the y-max for my "Original Data" plot. Below is my code but I only want to highlight the y-max for the "Original data" plot.
Thanks,
Ben
h = input("Initial height (m): "); %Initial height
angle = input("Initial Angle of elavation: "); %Degrees
v = input("Initial velocity (m/s): "); %M/S
g=-9.81; %M/S^2
angles = 0:10:180;
heights = 0:10:100;
velocity = 10:10:100;
figure
[x_val,y_val] = Arc(g,h,angle,v);
plot(x_val,y_val);
hold on;
xlabel 'x (m)'
ylabel 'y (m)'
title 'Original Data'
figure
for a = angles
[x_val,y_val] = Arc(g,h,a,v);
plot(x_val,y_val);
hold on;
end
xlabel 'x (m)'
ylabel 'y (m)'
title 'Angles 0-180'
figure
for hi = heights
[x_val,y_val] = Arc(g,hi,angle,v);
plot(x_val,y_val);
hold on;
end
xlabel 'x (m)'
ylabel 'y (m)'
title 'Height'
figure
for vel = velocity
[x_val,y_val] = Arc(g,h,angle,vel);
plot(x_val,y_val);
hold on;
end
xlabel 'x (m)'
ylabel 'y (m)'
title 'Velocity'
function [x_val,y_val] = Arc(g,h,angle,v)
y = h;
t = 0;
x_val = [];
y_val = [];
while y >= 0
y=.5*g*t.^2+v*sind(angle)*t+h;
x=v*cosd(angle)*t;
t = t + 0.01;
x_val = [x_val,x];
y_val = [y_val,y];
end
end
  1 件のコメント
Benjamin Nienhouse
Benjamin Nienhouse 2020 年 11 月 20 日
Thanks youuuu

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2020 年 11 月 18 日
plot(x_val,y_val);
hold on;
[~,idx] = max(y_val);
plot(x_val(idx),y_val(idx),'r*')
text(x_val(idx),y_val(idx),'max','VerticalAlignment','Bottom','HorizontalAlignment','Left','FontSize',8)
xlabel 'x (m)'
ylabel 'y (m)'
title 'Original Data'
  3 件のコメント
Benjamin Nienhouse
Benjamin Nienhouse 2020 年 11 月 19 日
Hey, if you have the time, I'm wondering how I can "slow down" the "original data" graph so it plots it like a movie (you can see it plotting on the screen) instead of just instantly plotting it.
Adam Danz
Adam Danz 2020 年 11 月 19 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by