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 comentarios

Jan
Jan el 10 de Nov. de 2016
Editada: Jan el 10 de Nov. de 2016
Did you notice that the code is not readable? Please use the "{} Code" button for a proper formatting of the code. Thanks.
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

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 10 de Nov. de 2016
Editada: Jan el 10 de Nov. de 2016
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)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 10 de Nov. de 2016

Editada:

el 10 de Nov. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by