need help with my function script
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Jan
il 10 Nov 2016
Modificato: Jan
il 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)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!