2D - Truss Analysis help

조회 수: 7 (최근 30일)
Ben
Ben 2014년 7월 4일
답변: marrwa manaa 2017년 10월 22일
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
Rick Rosson
Rick Rosson 2014년 7월 5일
Functions and scripts are two very different things in MATLAB.

댓글을 달려면 로그인하십시오.

답변 (2개)

marrwa manaa
marrwa manaa 2017년 10월 22일
plez if you complete ur program,send to me function script

per isakson
per isakson 2014년 7월 5일
편집: per isakson 2014년 7월 5일

카테고리

Help CenterFile Exchange에서 Structural Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by