2D - Truss Analysis help
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello all, i've been trying to develop a MATLAB code to analyze a 2-D truss system because I thought it would be a good project to further my understanding (i'm a beginner)
My main function script is here:
function Project
E = 10200000; % Modulus of Elasticity, Aluminum alloy (psi)
A = 200; % Cross-Sectional Area
L = 1; % Length of bar
EA = E*A;
elementNodes = [1 4; 2 4; 3 4; 4 6; 3 6; 3 5; 5 6; 5 7; 6 7];
nodeCoordinates = [0 1 ;0 0 ;1 1 ;1 0 ;2 1 ;2 0 ;3 1 ];
numberElements = size(elementNodes,1);
numberNodes = size(nodeCoordinates,1);
xx = nodeCoordinates(:,1);
yy = nodeCoordinates(:,2);
GDoF = 2 * numberNodes; % degrees of freedom
U = zeros(GDoF,1); % Displacement
force = zeros(GDoF,1);
% gravitational loads
force(4)= -2500;
force(5)= -2500;
force(6)= -2500;
force(7)= -5000;
% system stiffness matrix
[stiffness]=formStiffness2Dtruss(GDoF,numberElements,elementNodes,numberNodes,nodeCoordinates,xx,yy,EA);
% boundary conditions
prescribedDoF = [1 2 10]';
% Solution
displacements = solution(DoF,prescribedDoF,stiffness,force);
us = 1:2:2*numberNodes-1;
vs = 2:2:2*numberNodes;
end
---------------------------- My second script formStiffness2Dtruss (stiffness matrix)- is here :
function formStiffness2Dtruss
elementNodes = [1 4; 2 4; 3 4; 4 6; 3 6; 3 5; 5 6; 5 7; 6 7];
nodeCoordinates = [0 1 ;0 0 ;1 1 ;1 0 ;2 1 ;2 0 ;3 1 ];
numberElements = size(elementNodes,1);
numberNodes = size(nodeCoordinates,1);
stiffness = zeros(numberNodes);
for e=1:numberElements;
% elementDof: element degrees of freedom (Dof)
GDoF=elementNodes(e,:) ;
stiffness(GDoF,GDoF)=stiffness(GDoF,GDoF)+[1 -1;-1 1];
end
end
--------------------------- When I try and run the main function I get the error
Error using formStiffness2Dtruss
Too many input arguments.
Error in Project (line 26)
[stiffness] =
formStiffness2Dtruss(GDoF,numberElements,elementNodes,numberNodes,nodeCoordinates,xx,yy,EA);
--------------------------- I'm not sure what's really going on and how to fix the problem. Any help would be greatly appreciated! Thanks! (To clarify the second script (stiffness matrix) runs fine on it's own)
1 Kommentar
Antworten (2)
marrwa manaa
am 22 Okt. 2017
plez if you complete ur program,send to me function script
0 Kommentare
per isakson
am 5 Jul. 2014
Bearbeitet: per isakson
am 5 Jul. 2014
See:
- Programming Scripts and Functions
- Functions, Programs that accept inputs and return outputs
- Base and Function Workspaces
and do a few simple exercises
0 Kommentare
Siehe auch
Kategorien
Mehr zu Structural Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!