2D - Truss Analysis help
    9 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
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 Commento
Risposte (2)
  per isakson
      
      
 il 5 Lug 2014
        
      Modificato: per isakson
      
      
 il 5 Lug 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 Commenti
Vedere anche
Categorie
				Scopri di più su Structural Analysis in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!