필터 지우기
필터 지우기

How do I alter the curve of my plot

조회 수: 2 (최근 30일)
Thomas
Thomas 2023년 10월 8일
댓글: Sam Chak 2023년 10월 8일
% 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?

답변 (1개)

Sam Chak
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
Thomas
Thomas 2023년 10월 8일
Could you explain this line of code: 'i_h(end)-i_h, 'linewidth', 2)'?
Sam Chak
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)".

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by