How to save previous runs

1 回表示 (過去 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 Center および File Exchange2-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