How do I alter the curve of my plot
2 ビュー (過去 30 日間)
古いコメントを表示
% Set variables: g is gravity, v is velocity, i_h is initial height, h_f is final height
g = 9.81;
v = 85;
i_h = 0:0.25:95;
h_f = 0
% Equations: t being time and d being distance
t = sqrt(2*i_h\g);
d = (85*sqrt(2*i_h/g));
figure;
plot(d,i_h)
title 'i_h'
ylabel ('Height (m)')
xlabel ('Distance (m)')
grid on
How do I get my graph to start at coordinates 0, 95 and end at coordinates, 374.077, 0?
0 件のコメント
回答 (1 件)
Sam Chak
2023 年 10 月 8 日
g = 9.81;
v = 85;
i_h = 0:0.25:95;
h_f = 0;
% Equations: t being time and d being distance
t = sqrt(2*i_h\g);
d = (85*sqrt(2*i_h/g));
figure;
plot(d, i_h(end)-i_h, 'linewidth', 2)
title 'i_h'
ylabel ('Height (m)')
xlabel ('Distance (m)')
grid on
2 件のコメント
Sam Chak
2023 年 10 月 8 日
Alright @Thomas, i_h(end) is 95 m, and i_h is a vector array ranging from 0 to 95. Previously, the figure was plotted with i_h as the y-axis variable and d as the x-axis variable, using the syntax "plot(d, i_h)". This resulted in the graph starting from (0, 0).
In the image you provided, it seems you want to plot the graph starting from the highest point, which naturally means you want to plot from 95 m down to 0 (ground level). One way to achieve this is by defining a new y-axis variable, like ynew = 95 - i_h, and then plotting it using "plot(d, ynew)".
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!