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

 採用された回答

Star Strider
Star Strider 2016 年 2 月 4 日

1 投票

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 件のコメント

vignesh raju
vignesh raju 2016 年 2 月 4 日
Is it possible to write this as a script ? Rather than as a command line statement.
Star Strider
Star Strider 2016 年 2 月 4 日
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 2016 年 2 月 4 日
Thanks a lot. It worked.
Star Strider
Star Strider 2016 年 2 月 4 日
My pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by