Plotting Multiple Functions on One Line
7 views (last 30 days)
Show older comments
Lauren Quinones
on 5 Nov 2020
Commented: Lauren Quinones
on 5 Nov 2020
I need help with a homework assignment in terms of having all functions on one plot.
Below is the problem:
We want to understand the fine details of the relationships between the various properties of a material and its orientation. This is best done by developing your own code. Using MATLAB, recreate a figure similar to Figure 2.11 in Jones using the material properties listed below. They are representative of a boron/epoxy composite. It is ok to create a separate plot for Poisson's ratio. Please download and examine the attached MATLAB script (M) for expectations and hints on how to complete MATLAB assignments for this course.
- E1 = 45.0 x 106 psi
- E2 = 5.0 x 106 psi
- G12 = 1.5 x 106 psi
- v12 = 0.3
I have posted my code below. I was able to get Ex/E2 to successfully display, however when I try to add another function, Vxy, I cannot get it to display.
We are asked to replicate this plot:

So far I believe I know what functions I need use, I just need help with putting it on one plot. Also, it was suggested to use ratios? I.E. E1 could = 3? I am not sure what he meant about that part.
% The purpose of this code is to
% (1) We want to understand the fine details of the relationships between
%the various properties of a material and its orientation.
%This will be representative of a boron/epoxy composite
%just like the video, start by closing all existing windows and plots that
%are open and %clearing
%all variables
close all;
clear all;
%Define Material Properties if applicable
%boron-epoxy composite
E1 = 45.0*10^6;
E2 = 5.0*10^6;
G12 = 1.5*10^6;
v12 = .3;
%derived
v21 = v12*(E2/E1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Part 1 - Plot the ratios per figure 2.11 in Jones first part for Ex/E2
figure %create a new figure but hold it for the calculations to be made
hold on;
theta = linspace (0,90,18);
Ex = zeros(size(theta));
Vxy = zeros(size(theta));
for i = 1: length(theta)
theta(i)
[Ex(i)] = E_longitudinal (E1, E2, G12, v12, theta(i));
[Vxy(i)] = Vxy_longitudinal (E1, E2, G12, v12, theta(i));
end
plot(theta, Ex/E2, '-+r');%plot uses red squares
plot(theta, Vxy, '-+b');
xlabel ('\theta (degree)');
ylabel ('E_x/E_2', '|Vxy|');
legend ('E_x/E_2', 'Vxy');
yyaxis left;
pLeft = plot(theta, Ex/E2, 'bs', theta, Gxy/G12, 'ko', theta, -nxy, 'g+');
yyaxis right;
pRight = plot(theta, Vxy, 'rs');
xlabel('\theta (degree)');
yyaxis left;
ylabel('Ex/E_2, Gxy/G12, -\etaxy, x');
yyaxis right;
ylabel('\nuxy');
h = (pLeft; pRight);
legend(h, 'Ex/E2', 'Gxy/G12', '-\etaxy,x', '\nuxy');
hold off
%%%%%%%%%%%%%functions%%%%%%%%%%%%%%%%%%%%%%%
%Find longitudinal stiffness using eq 2.97
function [Ex] = E_longitudinal (E1, E2, G12, v12, theta)
%eq 2.97
E_Inverse = (1/E1)*(cosd(theta)^4) + (1/G12 - 2*v12/E1)*(sind(theta)^2)*(cosd(theta)^2) + (1/E2)*(sind(theta)^4);
Ex = 1/E_Inverse;
end
function [Vxy] = Vxy_longitudinal (E1, E2, G12, v12, theta)
Vxy = Ex*((V12/E1)*((sind(theta))^4+(cosd(theta))^4)-((1/E1)+(1/E2)-(1/G12))*(sind(theta))^2*(cosd(theta))^2);
end
0 Comments
Accepted Answer
Walter Roberson
on 5 Nov 2020
% The purpose of this code is to
% (1) We want to understand the fine details of the relationships between
%the various properties of a material and its orientation.
%This will be representative of a boron/epoxy composite
%just like the video, start by closing all existing windows and plots that
%are open and %clearing
%all variables
close all;
clear all;
%Define Material Properties if applicable
%boron-epoxy composite
E1 = 45.0*10^6;
E2 = 5.0*10^6;
G12 = 1.5*10^6;
v12 = .3;
%derived
v21 = v12*(E2/E1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Part 1 - Plot the ratios per figure 2.11 in Jones first part for Ex/E2
figure %create a new figure but hold it for the calculations to be made
hold on;
theta = linspace (0,90,18);
Ex = zeros(size(theta));
Vxy = zeros(size(theta));
for i = 1: length(theta)
theta(i)
[Ex(i)] = E_longitudinal (E1, E2, G12, v12, theta(i));
[Vxy(i)] = Vxy_longitudinal (E1, E2, G12, v12, Ex(i), theta(i)); %FIXED
end
plot(theta, Ex/E2, '-+r');%plot uses red squares
plot(theta, Vxy, '-+b');
xlabel ('\theta (degree)');
ylabel ({'E_x/E_2', '|Vxy|'}); %FIXED
legend ('E_x/E_2', 'Vxy');
yyaxis left;
pLeft = plot(theta, Ex/E2, 'bs', theta, Gxy/G12, 'ko', theta, -nxy, 'g+');
yyaxis right;
pRight = plot(theta, Vxy, 'rs');
xlabel('\theta (degree)');
yyaxis left;
ylabel('Ex/E_2, Gxy/G12, -\etaxy, x');
yyaxis right;
ylabel('\nuxy');
h = [pLeft; pRight]; %FIXED
legend(h, 'Ex/E2', 'Gxy/G12', '-\etaxy,x', '\nuxy');
hold off
%%%%%%%%%%%%%functions%%%%%%%%%%%%%%%%%%%%%%%
%Find longitudinal stiffness using eq 2.97
function [Ex] = E_longitudinal (E1, E2, G12, v12, theta)
%eq 2.97
E_Inverse = (1/E1)*(cosd(theta)^4) + (1/G12 - 2*v12/E1)*(sind(theta)^2)*(cosd(theta)^2) + (1/E2)*(sind(theta)^4);
Ex = 1/E_Inverse;
end
function [Vxy] = Vxy_longitudinal (E1, E2, G12, V12, Ex, theta) %FIXED
Vxy = Ex*((V12/E1)*((sind(theta))^4+(cosd(theta))^4)-((1/E1)+(1/E2)-(1/G12))*(sind(theta))^2*(cosd(theta))^2);
end
I cannot fix the Gxy problem as you have no code anywhere that defiens Gxy.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!