Filter löschen
Filter löschen

Saving plot with multiple inputs

1 Ansicht (letzte 30 Tage)
Joshua Fullerton-Harvey
Joshua Fullerton-Harvey am 13 Okt. 2019
Bearbeitet: Jackson Burns am 13 Okt. 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

Akzeptierte Antwort

Jackson Burns
Jackson Burns am 13 Okt. 2019
Bearbeitet: Jackson Burns am 13 Okt. 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')

Weitere Antworten (0)

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by