How to save previous runs

4 visualizzazioni (ultimi 30 giorni)
Peter Carchia
Peter Carchia il 9 Apr 2021
Modificato: Abhishek Gupta il 12 Apr 2021
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 Commento
KSSV
KSSV il 9 Apr 2021
You have data matrix (x,y) already in hand......you can plot it any time.

Accedi per commentare.

Risposte (1)

Abhishek Gupta
Abhishek Gupta il 12 Apr 2021
Modificato: Abhishek Gupta il 12 Apr 2021
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.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by