How to save multiple figures into a folder on desktop from a for loop?
Mostra commenti meno recenti
Hello,
I am trying to save all my figures, but don't want to run my code and then save each individual figure, can you help me speed up my process, thanks. Below is a copy of my code, I care about the for loop where z_plot is; that is outputing my figures. Also, I have written a lot of functions so if you try copying it and running it, it might give you issues.
-Robert
Safety_Factor = 2.5;
E1 = 190*10^9;
E2 = 9.9*10^9;
v12 = 0.35;
v21 = E2*(v12/E1);
G12 = 7.8*10^9;
alpha1 = -0.9*10^-6;
alpha2 = 22*10^-6;
F_1t = 3250*10^6; % Longitudinal Tensile Strength, measured in MPa
F_1c = -1590*10^6; % Longitudinal Compression Strength
F_2t = 62*10^6; % Transverse Tensile Strength
F_2c = -200*10^6; % Transverse Compression Strength
F_6 = 75*10^6; % In-Plane Shear Strength
Ultimate_ep_1t = 0.016;
Ultimate_ep_1c = abs(F_1c/E1);
Ultimate_ep_2t = .006;
Ultimate_ep_2c = abs(F_2c/E2);
Ultimate_ep_shear = abs(F_2t/G12);
Q = Q_Matrix(E1,E2,v12,v21,G12);
Angles = input('Insert Angles in Matrix Form ')
Thickness = input('Insert Thickness of Ply ')
Number_of_Plys = length(Angles);
Failed = zeros(Number_of_Plys,1);
Delta_Temp = input('Insert Temperature Difference ')
Thermal_Strain = Delta_Temp*[alpha1; alpha2; 0];
first = 0;
rerun = 1;
while rerun == 1
rerun = 0;
[ABD, Thermal_Load] = ABD_Matrix_and_Thermal_Loads(Angles,Thickness,Failed,E1,E2,v12,v21,G12,Thermal_Strain);
%Force_Load = [0.6*10^6;0.3*10^6;0;0.3;0;0]*Safety_Factor;
%Force_Load = [0;0;0.1;0;0.3;0]*Safety_Factor;
%Force_Load = [0;0;0;0;0;0.3]; % For this one multiply just the total load by the safety factor
%Force_Load = [0;0;0;10;0;0];
Total_Load = Force_Load + Thermal_Load
[Stress_XY, Strain_XY, Stress_12, Strain_12] = All_Stresses_and_Strains(ABD,Thickness,Angles,Total_Load,E1,E2,v12,v21,G12,Failed);
Stress_XY;
Stress_12;
Strain_XY;
Strain_12;
% Max Stress Failure Criteria
Fail_Sum_Old = sum(Failed);
[Failed_out] = Max_Stress_Failure_Criteria(Stress_12,Failed,F_1t,F_1c,F_2t,F_2c,F_6);
Failed_out
Fail_Sum_New = sum(Failed_out);
% if Fail_Sum_New > Fail_Sum_Old && Fail_Sum_New ~= 3*length(Failed)
% rerun = 1;
% Failed = Failed_out;
% end
% Hashim-Rotem
Failed;
Fail_Old_Sum = sum(Failed);
[Failed_Out_HR] = Hashin_Rotem_Failure_Criteria(Stress_12,F_6,F_2t,F_2c,F_1t,F_1c,Failed,Ultimate_ep_shear,Ultimate_ep_1t,Ultimate_ep_1c,Ultimate_ep_2t,Ultimate_ep_2c);
Failed_Out_HR
Fail_New_Sum = sum(Failed_Out_HR);
if Fail_New_Sum > Fail_Old_Sum && Fail_New_Sum ~= 3*length(Failed)
rerun = 1;
Failed = Failed_Out_HR;
end
% if first == 0
for i=1:3
z_plot(Strain_12(i,:),Strain_XY(i,:),Stress_XY(i,:),Stress_12(i,:),Thickness,(i-1))
end
% first = 1;
% z_plot
% Failed_out
% ABD
% end
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Subplots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

