need help with my function script
조회 수: 1 (최근 30일)
이전 댓글 표시
This code is giving me error message (FUNCTION keyword use is invalid here, this might cause later message about END).
*function[k,m]=feframe2(el,xi;leng;area;rho;beta;ipt)*
a=el*area/leng;
c=el*xi/(leng^3);
kl=[a 0 0 -a 0 0;...
0 12*c 6*leng*c 0 -12*c 6*leng*c;...
0 6*leng*c 4*leng^2*c 0 -6*leng*c 2*leng^2*c;...
-a 0 0 a 0 0;...
0 -12*c -6*leng*c 0 12*c -6*leng*c;...
0 6*leng*c 2*leng^2*c 0 -6*leng*c 4*leng^2*c];
%matrice di rotazione
r=[cos(beta) sin(beta) 0 0 0 0;...
-sin(beta) cos(beta) 0 0 0 0;...
0 0 1 0 0 0;...
0 0 0 cos(beta) sin(beta) 0;...
0 0 0 -sin(beta) cos(beta) 0;...
0 0 0 0 0 1];
%matrice di rigidezza globale
k=r'*kl*r
%consistent mass matrix
%
if ipt==1
%
mm=rho*area*leng/420;
ma=rho*area*leng/6;
ml=[2*ma 0 0 ma 0 0;...
0 156*mm 22*leng*mm 0 54*mm -13*leng*mm;...
0 22*leng*mm 4*leng^2*mm 0 13*leng*mm -3*leng^2*mm;...
ma 0 0 2*ma 0 0;...
0 54*mm 13*leng*mm 0 156*mm -22*leng*mm;...
0 -13*leng*mm -3*leng^2*mm 0 -22*leng*mm 4*leng^2*mm];
%lumped mass matrix
%
elseif ipt==2
%
ml=zeros(6,6);
mass=rho*area*leng;
ml=mass*diag([0.5 0.5 0 0.5 0.5 0]);
%diagonal mass matrix
%
else
%
ml=zeros(6,6);
mass=rho*area*leng;
ml=mass*diag([0.5 0.5 leng^2/78 0.5 0.5 leng^2/78]);
%
end
%mass in the global system
%
m=r'*ml*r;
댓글 수: 2
답변 (1개)
Jan
2016년 11월 10일
편집: Jan
2016년 11월 10일
Did search in the internet for "FUNCTION keyword use is invalid here"? You can find the explanation, that function cannot be declared in scripts or in the command line. They are allowed only in M-files which start with the term "function", which are called M-functions in comaprison to M-scripts.
Do not use semicolons to separate the input arguments:
feframe2(el,xi;leng;area;rho;beta;ipt)
==>
feframe2(el,xi,leng,area,rho,beta,ipt)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!