Effacer les filtres
Effacer les filtres

How do I alter the curve of my plot

2 vues (au cours des 30 derniers jours)
Thomas
Thomas le 8 Oct 2023
Commenté : Sam Chak le 8 Oct 2023
% 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?

Réponses (1)

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by