MATLAB Answers

0

Plotting graph with uneven amount of vectors

Asked by maximumdv on 14 Feb 2019
Latest activity Commented on by Walter Roberson
on 14 Feb 2019
Hello everyone,
So, I want to plot a graph pressure over volume. Both values have been measured over a time of 0.85 seconds, however the pressure has been recorded at a 170 moments and the volume has been recorded at only 69 moments. How can I make this work?

  0 Comments

Sign in to comment.

1 Answer

Answer by Walter Roberson
on 14 Feb 2019
 Accepted Answer

take the later of the two start times and the earlier of the two end times. linspace some points between the two. interp1 the pressure at those query points and the temperature at those query points . Now you can plot the interpolated values against each other .

  3 Comments

Both values have been recorded from 0-0.85 seconds the pressure has just been recorded more often. Also the graph is supposed to look like a loop, a pressure-volume loop so using linspace for some points does not really work. Do you have any other suggestions?
you would linspace on time. Time will not loop but the parametric plot of pressure vs volume could loop.
N = 100;
qt = linspace(0, 0.85, N);
qp = interp1(times_pressure_recorded_at, recorded_pressures, qt);
qv = interp1(times_volume_recorded_at, recorded_volumes, qt);
plot(qv, qp);

Sign in to comment.