Code not working?

2 views (last 30 days)
Briana Canet
Briana Canet on 26 Jan 2022
Answered: Star Strider on 26 Jan 2022
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

Answers (2)

VBBV
VBBV on 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
E_3c = 1×11
1.0e+05 * 0.0132 0.2399 0.4666 0.6933 0.9200 1.1466 1.3733 1.6000 1.8267 2.0533 2.2800
% Shear modulus of the composite
G_3c = (((f_f/E_f)+((1-f_f)/E_m)).^-1) % MPa
G_3c = 1×11
1.0e+05 * 0.0132 0.0147 0.0165 0.0189 0.0220 0.0263 0.0328 0.0436 0.0647 0.1259 2.2800
% Contribution of the shear to the beam deflection, z
ds_db = ((6/5)*(E_3c./G_3c).*((t_L).^2))
ds_db = 1×11
0.0120 0.1957 0.3386 0.4406 0.5018 0.5222 0.5018 0.4406 0.3386 0.1957 0.0120
% 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 Comment
VBBV
VBBV on 26 Jan 2022
fiber volume fraction vector seems incorrect.

Sign in to comment.


Star Strider
Star Strider on 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))
ds_db = 1×101
0.0120 0.0322 0.0520 0.0714 0.0904 0.1089 0.1271 0.1449 0.1622 0.1792 0.1957 0.2118 0.2275 0.2428 0.2577 0.2722 0.2863 0.3000 0.3132 0.3261 0.3386 0.3506 0.3622 0.3735 0.3843 0.3947 0.4047 0.4143 0.4235 0.4322
% 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
.

Categories

Find more on Chemistry 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!