I have a code that I would like to modify to plot multiple items all together
Show older comments
I have this code
% Matrix properties (Al2O3)
Em = 380E3; % Young's modulus
num = 0.22; % Poisson's ratio
Vv_vals = [0.01, 0.35, 0.47]; % different porosity volumes
KIc = 3.63; % MPa*sqrt(m) fracture toughness
% Dv = 1E-3; % void diameter
%
Porous_AL2O3;
% Crack density parameter (from Budiansky and O'Connel, IJSS 12:81-97, 1976)
cdp0 = 0;
cdp = cdp0;
a = 1;
%
%%
% MECHANISMS OF CYCLIC FATIGUE-CRACK PROPAGATION IN A FINE-GRAINED ALUMINA
% CERAMIC: THE ROLE OF CRACK CLOSURE C. J. Gilbert, R. O. Ritchie 2008
C = 1.3E-18; % Paris law coefficient
m = 23; % material exponent
delta_gmcv = 2.5;
%
%%
N_cycles = 1E7;
sigma_avg = [569, 59, 13]; % average strength
sigma_max = [0.9*sigma_avg 0.8*sigma_avg 0.7*sigma_avg 0.6*sigma_avg; 0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0]; % max stress
% needs to be 0.9, 0.8, 0,7, and 0.6 of sigma_avg for the three Vv_vals
R = sigma_min/sigma_max; % stress ratio
%%
%% Critical eneergy release rate for matrix
GIc = KIc^2/Em*1000;
% eps_step = zeros(6,6);
rmcv = 2/3*(1-Vv_vals)*pi*GIc/a;
% Stiffness and compliance matrices of uncracked material (6 x 6)
[S2m,C2m] = S2_C2_ortho(Em,Em,Em,num,num,num,Em/2/(1+num),Em/2/(1+num),Em/2/(1+num)); % matrix
%
num_Vv = length(Vv_vals);
for Vv_idx = 1 : num_Vv
Vv = Vv_vals(Vv_idx);
for k = 1:N_cycles
% F tensor for crakcs
Fc = F_tens_penny_iso(num);
%
% Swap axis 3 with axis 1 (so axis 3 of the crack is aligned with material axis 1)
Fc = Fc([3 2 1 6 5 4],[3 2 1 6 5 4]);
%
% Strain concentration tensor for voids
[~,SE2v] = eshelby_tens_sph_iso(num); % Eshelby tensor for voids
inv_Tv = eye(6)-SE2v; % inverse T tensor for voids
Tv = inv_Tv\eye(6); % T tensor for voids
% Homogenised stiffness and compliance with voids and cracks
inv_Am = (1-Vv)*eye(6) + Vv*Tv + cdp*Fc; % inverse absolute strain concentration tensor for the matrix
Am = inv_Am\eye(6); % absolute strain concentration tensor for the matrix
C2 = (1-Vv)*C2m*Am; % stiffness tensor of matrix + cracks + voids
S2 = C2\eye(6); % compliance tensor of matrix + cracks + voids
%
%
% Equivalent elastic moduli from compliance matrix
%
[E1,E2,E3,nu12,nu13,nu23,G12,G13,G23] = moduli_ortho(S2);
eps_max = S2*sigma_max;
s_mcv = C2*eps_max;
eps_mcv_max = Am*eps_max;
s_mcv_max = Am*s_mcv;
gmcv_max = 1/2*(1-Vv)*eps_mcv_max'*C2*Am*Fc*Am*eps_mcv_max;
cdp = cdp + C * (delta_gmcv)^m * k;
eps_mcv_step(:,k) = eps_mcv_max;
s_mcv_step(:,k) = s_mcv_max;
end
end
loglog(s_mcv_step(1,:),'r','LineWidth',2)
hold
loglog(AL01_SIGMA08(:,1),AL01_SIGMA08(:,2),'bo','MarkerSize',8,'MarkerFaceColor',[0 0 1])
loglog(meanAL0108(:,1),meanAL0108(:,2),'bo','MarkerSize',8,'MarkerFaceColor',[0 1 1])
there is one material which has three varying porosities (0.01, 0.35, and 0.47). Each case is being loaded to 0.9,0.8,0.7, and 0.6 of their average respective strengths. the test data is found in
Porous_AL2O3
Which has 12 data sets. I would like to take the mean of each data set and then plot all of it against each other to generat a graph that resembles this one but with the 12 different data sets, their means and the respective comparison all on the same plot

I realise that this maybe a bit of a huge ask but any help is greatly welcomed.
Thanks
Alex
6 Comments
Govind KM
on 6 Jun 2023
Since you have used hold, you can continue plotting data for each of the datasets and they will appear on the same plot.
A Poyser
on 6 Jun 2023
Chris Burschyk
on 6 Jun 2023
You could multiply your average Strength with [0.9:-0.1:0.6] and adjust your code to use piecewise multiplication and devision (just add a "." before "*" and "/").
But I don't fully understand your code. A lot of the calculations inside the loops seem to be the same every time, maybe do these outside of the loop.
A Poyser
on 6 Jun 2023
Chris Burschyk
on 6 Jun 2023
Everything in the loop before the line
inv_Am = (1-Vv)*eye(6) + Vv*Tv + cdp*Fc;
is calculated everytime but it doesnt get changed because the variable "num" stays at 0.22.
For your plotting problem I could suggest to put one more loop between the two which iterates over the different loads
figure()
hold on
for Vv_idx = 1 : num_Vv
for idx_load = 0:4
Vv = Vv_vals(Vv_idx) * (1-(idx_load/10);
for k = 1:N_cycles
...
end
loglog(s_mcv_step(1,:),'r','LineWidth',2)
end
end
hold off
This will give you only the red lines for each Iteration. As for the means I do not know how your dataset looks like so its hard to give you advice on that.
A Poyser
on 6 Jun 2023
Accepted Answer
More Answers (0)
Categories
Find more on Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!