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);

 Accepted Answer

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 Comments

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.
Thanks a lot. It worked.
My pleasure.

Sign in to comment.

More Answers (0)

Categories

Products

Tags

Community Treasure Hunt

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

Start Hunting!