Saving plot with multiple inputs

1 次查看(过去 30 天)
% "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

采纳的回答

Jackson Burns
Jackson Burns 2019-10-13
编辑:Jackson Burns 2019-10-13
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')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by