Hello, I am creating a programme to solve a 6 DOF truss and I am using matlab to calculate the forces and sdisplacement using the stiffness matrix method, however I am recieving the wrong answers

2 visualizaciones (últimos 30 días)
clc
clear
E= (2.1*10^(11));
A = ((0.01/2)^(2)*pi());
L = 1;
st = (E*A)/L;
s1 = sind(0);
c1 = cosd(0);
s2 = sind(120);
c2 = cosd(120);
s3 = sind(60);
c3 = cosd(60);
k1 = stiffy(st,s1,c1);
k2 = stiffy(st,s2,c2);
k3 = stiffy(st,s3,c3);
K = glob(k1,k2,k3);
syms f1x f1y f2y;
f =[f1x;
f1y;
0;
f2y;
0;
-1000;];
syms u2x u3x u3y;
u =[0;
0;
u2x;
0;
u3x;
u3y;];
ku = K*u;
eq(1) = ku(1) == f(1);
eq(2) = ku(2) == f(2);
eq(3) = ku(3) == f(3);
eq(4) = ku(4) == f(4);
eq(5) = ku(5) == f(5);
eq(6) = ku(6) == f(6);
sol = solve(eq,[f1x,f1y,f2y,u2x,u3x,u3y]);
solf1x = sol.f1x;
solf1y = sol.f1y;
solf2y = sol.f2y;
solu2x = sol.u2x;
solu3x = sol.u3x;
solu3y = sol.u3y;
f1x = int64(solf1x)
f1y = int64(solf1y)
f2y = int64(solf2y)
u2x = int64(solu2x)
u3x = int64(solu3x)
u3y = int64(solu3y)
function [k] = stiffy(st,s,c)
ke = [c^2,s*c,-(c^2),-(s*c);
s*c,s^2,-(s*c),-(s^2);
-(c^2),-(s*c),c^2,s*c
-(s*c),-(s^2),s*c,s^2];
k = ke*st;
end
function [K] = glob(k1,k2,k3)
K =[k1(1,1)+k3(1,1),k1(1,2)+k3(1,2),k1(1,3),k1(1,4),k3(1,3),k3(1,4);
k1(2,1)+k3(2,1),k1(2,2)+k3(2,2),k1(2,3),k1(2,4),k3(2,3),k3(2,4);
k1(3,1),k1(3,2),k1(3,3)+k2(1,1),k1(3,4)+k2(1,2),k2(1,3),k2(1,4);
k1(4,1),k1(4,2),k1(4,3)+k2(2,1),k1(4,4)+k2(2,2),k2(2,3),k2(2,4);
k3(3,1),k3(3,2),k2(3,1),k2(3,2),k2(3,3)+k3(3,3),k2(3,4)+k3(3,4);
k3(4,1),k3(4,2),k2(4,1),k2(4,2),k2(4,3)+k3(4,3),k2(4,4)+k3(4,4);];
end

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by