Saving plot with multiple inputs

1 vue (au cours des 30 derniers jours)
Joshua Fullerton-Harvey
Joshua Fullerton-Harvey le 13 Oct 2019
Modifié(e) : Jackson Burns le 13 Oct 2019
% "Produce a single plot containing the horizontal displacement
% as a function of time from the recorded data"
x = 1:0.01:10
y = x.^2
z = x.^3
a = plot(x,y,x,z)
xlabel('Time (seconds)')
ylabel('Horizontal displacement (m)')
title('Part 5')
legend('Attempt 1', 'Attempt 2')
saveas(a,'Plot 5.jpg')
Trying to save a plot with multiple inputs into a jpg file. Unable to do so. Can someone please help

Réponse acceptée

Jackson Burns
Jackson Burns le 13 Oct 2019
Modifié(e) : Jackson Burns le 13 Oct 2019
Hi Joshua!
saveas needs a figure handle to save. assigning a to the output of plot gives you a line instead. Fix it with this:
% "Produce a single plot containing the horizontal displacement
% as a function of time from the recorded data"
x = 1:0.01:10;
y = x.^2;
z = x.^3;
a = figure;
plot(x,y,x,z)
xlabel('Time (seconds)')
ylabel('Horizontal displacement (m)')
title('Part 5')
legend('Attempt 1', 'Attempt 2')
saveas(a,'Plot 5.jpg')

Plus de réponses (0)

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by