need help with my function script

10 vues (au cours des 30 derniers jours)
Andrea Daloisio
Andrea Daloisio le 10 Nov 2016
Modifié(e) : Thorsten le 10 Nov 2016
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 commentaires
Jan
Jan le 10 Nov 2016
Modifié(e) : Jan le 10 Nov 2016
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 le 10 Nov 2016
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

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 10 Nov 2016
Modifié(e) : Jan le 10 Nov 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)
  1 commentaire
Andrea Daloisio
Andrea Daloisio le 10 Nov 2016
thanks Jan for the answer.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by