need help with my function script

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 件のコメント

Jan
Jan 2016 年 11 月 10 日
編集済み: Jan 2016 年 11 月 10 日
Did you notice that the code is not readable? Please use the "{} Code" button for a proper formatting of the code. Thanks.
Andrea Daloisio
Andrea Daloisio 2016 年 11 月 10 日
if true
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;
end

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2016 年 11 月 10 日
編集済み: Jan 2016 年 11 月 10 日

0 投票

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)

1 件のコメント

Andrea Daloisio
Andrea Daloisio 2016 年 11 月 10 日
thanks Jan for the answer.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

タグが未入力です。

質問済み:

2016 年 11 月 10 日

編集済み:

2016 年 11 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by