2D - Truss Analysis help

44 ビュー (過去 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 Center および File ExchangeStructural Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by