How to save previous runs

조회 수: 2 (최근 30일)
Peter Carchia
Peter Carchia 2021년 4월 9일
편집: Abhishek Gupta 2021년 4월 12일
Hellp, I am creating a projectile motion simulation. Each time I run it I have 3 graphs being created. I am wondering how I can save those 3 graphs without them being deleted when I enter new inputs. This is what I have now...
%Projectile motion of a golf ball (no air resistance)
t = 0:.5:7.8; %time vector
u = 41; %inital velocity
angle = [25; 55; 85] %optimal angle
theta = unitsratio ('rad','deg')*angle
g = 9.8;
ux =u.*cos(theta); %velocity x direction
uy = u.*sin(theta) %velocity y direction
x = ux*t; %equation of motion, constant velocity
y= uy*t -0.5*g*t.^2; %equation of motion, constant velocity, resisted by gravity
for j = 1:size(angle,1)
for i = 1:size(x,2)
% if(i>1) && (y1(i)<0) %stop plotting when ball hits the ground
% break;
% end
plot (x(j,i),y(j,i),('*'));
hold on;
pause(0.01);
end
end
title 'flight of golf ball'
xlabel 'meters'
ylabel 'meters'
hgreen = plot(x1, y1, 'g-');
hblack = plot(x2, y2, 'k-');
  댓글 수: 1
KSSV
KSSV 2021년 4월 9일
You have data matrix (x,y) already in hand......you can plot it any time.

댓글을 달려면 로그인하십시오.

답변 (1개)

Abhishek Gupta
Abhishek Gupta 2021년 4월 12일
편집: Abhishek Gupta 2021년 4월 12일
Hi,
You can save the graphs with the save name having input variables, as follow: -
saveas(gcf, strcat('angles', {' '}, strjoin(string(angle)), '.png'));
The output figure name would be "angles 25 55 85.png" for the given input values.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by