フィルターのクリア

Plotting h(x) and v(x) function with user input of h0 and v0.

2 ビュー (過去 30 日間)
Weichieh Tu
Weichieh Tu 2020 年 1 月 31 日
コメント済み: KSSV 2020 年 1 月 31 日
g=-9.81;
h0=input('Enter the initial height in meters');
v0=input('Enter the initial velocity in meters/seconds');
%t=[1,2,3,4,5,6,7,8,9,10];
%t=linspace(0,5,100);
h=(0.5*g*t.^2)+(v0*t)+h0;
tt = find(h<=0);
t=[1:tt];
hv=(0.5*g*t.^2)+(v0*t)+h0;
I need to stop the plot from going below h(t)=0 for any given h0 and v0. Thanks.

採用された回答

KSSV
KSSV 2020 年 1 月 31 日
g=-9.81;
h0=input('Enter the initial height in meters');
v0=input('Enter the initial velocity in meters/seconds');
%t=[1,2,3,4,5,6,7,8,9,10];
t=linspace(0,5,100);
h=(0.5*g*t.^2)+(v0*t)+h0;
tt = t(h>=0) ;
hv=(0.5*g*tt.^2)+(v0*tt)+h0;
plot(tt,hv)
  2 件のコメント
Weichieh Tu
Weichieh Tu 2020 年 1 月 31 日
Thank you so much! Works like charm. If you don't mind me asking, what does plot(tt,hv) do?
KSSV
KSSV 2020 年 1 月 31 日
plot plots the data. Read the documentation of plot or check help plot

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by