Azzera filtri
Azzera filtri

Saving plot with multiple inputs

1 visualizzazione (ultimi 30 giorni)
% "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

Risposta accettata

Jackson Burns
Jackson Burns il 13 Ott 2019
Modificato: Jackson Burns il 13 Ott 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')

Più risposte (0)

Categorie

Scopri di più su Printing and Saving in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by