error in function b=2*pi*ones(n,1);
2 views (last 30 days)
Show older comments
Hi guys, I create this function to solve a manual shear type chase on Matlab:
function[T,Mpar,Mfinale,autovettori,autovalori] = telaio(M,K) C=M\K; [autovettori,autovalori]=eig(C); a=diag(autovalori); omega=a.^0.5; b=2*pi*ones(4,1); T=b./omega; Mstar=autovettori'*M*autovettori; Num=autovettori'*M*ones(4,1); gamma=Num'/Mstar; MSTAR=diag(Mstar)'; Mpar=(gamma.^2).*MSTAR; [Mtot]=sum(Mpar); Mfinale=ones(4,1); for i=4:-1:1 Mfinale(i)=Mpar(i)/Mtot*100; end
when I write in the EDU>> telaio(M,K) (with M and K just defined in the work space) I have this error: Error in telaio (line 6) b=2*pi*ones(n,1);
anybody can help me?! Please!
Thanks a lot!
0 Comments
Answers (1)
Star Strider
on 2 Nov 2014
I can’t reproduce your error. I don’t know what ‘M’ and ‘K’ are supposed to be, but
M = 7;
K = 5;
[T,Mpar,Mfinale,autovettori,autovalori] = telaio(M,K)
runs without error.
I noticed however, that the code you attached is not the code you apparently ran that threw the error. Line #6 in your code is:
b=2*pi*ones(4,1);
but the error is in this line:
b=2*pi*ones(n,1);
with ‘n’ undefined.
See if changing your function declaration statement to:
function[T,Mpar,Mfinale,autovettori,autovalori] = telaio(M,K,n)
to pass ‘n’ as a parameter, or define ‘n’ from the size of your matrices.
4 Comments
Star Strider
on 2 Nov 2014
My pleasure!
I honestly do not have any idea what the problem is with your code. I have no idea what you are doing.
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!