How to save previous runs

4 visualizaciones (últimos 30 días)
Peter Carchia
Peter Carchia el 9 de Abr. de 2021
Editada: Abhishek Gupta el 12 de Abr. de 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 comentario
KSSV
KSSV el 9 de Abr. de 2021
You have data matrix (x,y) already in hand......you can plot it any time.

Iniciar sesión para comentar.

Respuestas (1)

Abhishek Gupta
Abhishek Gupta el 12 de Abr. de 2021
Editada: Abhishek Gupta el 12 de Abr. de 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.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by