Get left and right side argument trying to execute this code, any suggestions on how to fix it?
Show older comments
close all;
clear all;
% Material Properties of Boron/Epoxy composite
E1 = 30*10^6;
E2 = 3*10^6;
G12 = 1*10^6;
v12 = .3;
v21 = v12*(E2/E1);
% setting the zeros for the functions
figure
hold on;
theta = linspace(0,90,18);
Ex = zeros(size(theta));
Gxy = zeros(size(theta));
vxy = zeros(size(theta));
nxyx = zeros(size(theta));
% defining the functions
for i=1: length(theta)
theta(i)
[Ex(i)] = Ex_lon(E1,E2,G12,v12,theta(i));
[Gxy(i)] = Gxy_lon(E1,E2,G12,v12,theta(i));
[vxy(i)] = vxy_lon(Ex E1,E2,G12,v12,theta(i));
[nxyx(i)] = nxyx_lon(Ex E1,E2,G12,v12,theta(i));
end
% generating the plot
plot(theta,Ex/E2,'-+r',theta,Gxy/G12,'-*g',theta,vxy,'-^b',theta,nxyx,'-xk');
xlabel('\theta (degree)');
yyaxis left;
ylabel('E_x/E_2, Gxy/G12, -nxyx');
yyaxis right;
ylabel('vxy');
legend('E_x/E_2','Gxy/G12','vxy','-nxyx');
hold off
% the following are the functions that the previously defined functions are
% called to
function [Ex] = Ex_lon(E1,E2,G12,v12,theta)
E_inv = (1/E1)*(cosd(theta)^4) + (1/G12- 2*v12/E1)*(sind(theta)^2)*(cosd(theta)^2) + (1/E2)*(sind(theta)^4);
Ex = (1/E_inv);
end
function [Gxy] = Gxy_lon(E1,E2,G12,v12,theta)
Gxy_inv = 2*(2/E1 + 2/E2 + 4*v12/E1 - 1/G12)*(sind(theta)^2)*(cosd(theta)^2)+ 1/G12*((sind(theta)^4)+(cosd(theta)^4));
Gxy = 1/Gxy_inv;
end
function [vxy] = vxy_lon(Ex,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
function [nxyx] = nxyx_lon(Ex E1,E2,G12,v12,theta)
nxyx = Ex*((2/E1 + 2/E2 - 1/G12)*(sind(theta))*(cosd(theta)^3)-(2/E2 +2*v12/E1 - 1/G12)*(sind(theta)^3)*(cosd(theta)));
end
7 Comments
KALYAN ACHARJYA
on 9 Nov 2019
There is the issue as the all output arguments of different function are vectors, you are trying to save all those output arguments in array???
for i=1:length(theta)
Ex(i)=Ex_lon(E1,E2,G12,v12,theta(i));
Gxy(i)=Gxy_lon(E1,E2,G12,v12,theta(i));
vxy(i)=vxy_lon(Ex,E1,E2,G12,v12,theta(i));
nxyx(i)=nxyx_lon(Ex,E1,E2,G12,v12,theta(i));
end
Also note on "./" vector dot operation.
Walter Roberson
on 9 Nov 2019
Yes, vxy_lon passes the vector Ex in and uses the entire vector. Perhaps it should only be passing Ex(i) in; likewise on the next line.
Kevin Harnett
on 9 Nov 2019
Kevin Harnett
on 9 Nov 2019
Kevin Harnett
on 9 Nov 2019
darova
on 9 Nov 2019

Walter Roberson
on 9 Nov 2019
No Answer was created, so none can be accepted.
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!