Code not working?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This code is plotting incorrectly. The plot in the x-axis should range from 0 to 1 and right now it is -1 to 1.
Also, no curve is being plotted with the code below.
clear; clc;
% Given data
E_f = 228000; % Elastic modulus of the fiber
E_m = 1325; % Elastic modulus of the matrix
G_f = 15000; % Shear modulus of the fiber
G_m = 400; % Shear modulus of the matrix
t_L = 1/10; % Aspect ratio of beam
% Fiber volume fraction
f_f = 0:100:1;
% 0 is 0% fiber and 1 is 100% fiber content
% points to be plotted
% Elastic modulus of the composite
E_3c = (E_f*f_f)+(E_m*(1-f_f)); % MPa
% Shear modulus of the composite
G_3c = (((f_f/E_f)+((1-f_f)/E_m))^-1); % MPa
% Contribution of the shear to the beam deflection, z
ds_db = ((6/5)*(E_3c/G_3c)*((t_L)^2));
% Plotting
plot(f_f,ds_db, 'Color', 'blue');
grid on;
title('Contribution of Shear to Beam Deflection vs. Fiber Volume Fraction')
xlabel('Volume fiber fraction, f_f')
ylabel('Contribution of Shear to Beam Deflection, ds/db [MPa]')
hold on
0 commentaires
Réponses (2)
VBBV
le 26 Jan 2022
clear; clc;
% Given data
E_f = 228000; % Elastic modulus of the fiber
E_m = 1325; % Elastic modulus of the matrix
G_f = 15000; % Shear modulus of the fiber
G_m = 400; % Shear modulus of the matrix
t_L = 1/10; % Aspect ratio of beam
% Fiber volume fraction
f_f = 0:0.1:1; % give p
% 0 is 0% fiber and 1 is 100% fiber content
% points to be plotted
% Elastic modulus of the composite
E_3c = (E_f*f_f)+(E_m*(1-f_f)) % MPa
% Shear modulus of the composite
G_3c = (((f_f/E_f)+((1-f_f)/E_m)).^-1) % MPa
% Contribution of the shear to the beam deflection, z
ds_db = ((6/5)*(E_3c./G_3c).*((t_L).^2))
% Plotting
plot(f_f,ds_db, 'Color', 'blue');
grid on;
title('Contribution of Shear to Beam Deflection vs. Fiber Volume Fraction')
xlabel('Volume fiber fraction, f_f')
ylabel('Contribution of Shear to Beam Deflection, ds/db [MPa]')
hold on
check with this
1 commentaire
Star Strider
le 26 Jan 2022
It plots correctly if ‘f_f’ is defined correctly. The middle value for colon-operator generated sequences is the ‘step’ value, so that the interval from one value to the next is the ‘step’ value. See colon,: for details.
Anyway, with that change, it works —
% clear; clc;
% Given data
E_f = 228000; % Elastic modulus of the fiber
E_m = 1325; % Elastic modulus of the matrix
G_f = 15000; % Shear modulus of the fiber
G_m = 400; % Shear modulus of the matrix
t_L = 1/10; % Aspect ratio of beam
% Fiber volume fraction
f_f = 0:0.0100:1;
% 0 is 0% fiber and 1 is 100% fiber content
% points to be plotted
% Elastic modulus of the composite
E_3c = (E_f*f_f)+(E_m.*(1-f_f)); % MPa
% Shear modulus of the composite
G_3c = (((f_f/E_f)+((1-f_f)/E_m)).^-1); % MPa
% Contribution of the shear to the beam deflection, z
ds_db = ((6/5)*(E_3c./G_3c)*((t_L)^2))
% Plotting
plot(f_f,ds_db, 'Color', 'blue');
grid on;
title('Contribution of Shear to Beam Deflection vs. Fiber Volume Fraction')
xlabel('Volume fiber fraction, f_f')
ylabel('Contribution of Shear to Beam Deflection, ds/db [MPa]')
hold on
.
0 commentaires
Voir également
Catégories
En savoir plus sur Bodies dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

