Error "not enough input arguments"

Hi all, I'm new to MatLab and I'm trying to run this code below with the file saved as eigencentrality.m and when I run in Command it gives the above error.
Have searched the forum but unable to figure out the solution for this. Please help.
%eigen centrality
function x=eigencentrality(A)
[V,D]=eig(A); [max_eig,ind]=max(diag(D)); x=V(:,ind);

 Respuesta aceptada

Star Strider
Star Strider el 4 de Feb. de 2016
You have to call your function as:
A = [1 2; 3 4];
x=eigencentrality(A)
You cannot run it as you would a script.

4 comentarios

vignesh raju
vignesh raju el 4 de Feb. de 2016
Is it possible to write this as a script ? Rather than as a command line statement.
Yes. Open the Editor, type in the text of your function just as you did in your Question. Then save it on your MATLAB search path with the file name eigencentrality.m
An alternate way of opening the editor to create your file is to type in the Command Window:
edit eigencentrality.m
Then type your text in the editor window that command creates, and save your file.
To use it, call it as I outlined above, just as you would any other function.
See the documentation on Function Basics for all the fascinating details.
vignesh raju
vignesh raju el 4 de Feb. de 2016
Thanks a lot. It worked.
Star Strider
Star Strider el 4 de Feb. de 2016
My pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 4 de Feb. de 2016

Comentada:

el 4 de Feb. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by