why we use same parenthesis for function calling and array?

a=fun(1,2) is used to call function fun and at the same time we use fun=randi(3,3) a=fun(1,2) to extract 1st row 2nd column of fun

1 件のコメント

deepak
deepak 2012 年 10 月 22 日
編集済み: deepak 2012 年 10 月 22 日
send some other answers in words

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

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 10 月 22 日
編集済み: Andrei Bobrov 2012 年 10 月 22 日

0 投票

function out = yourfun(a,b)
m = randi(3,3);
out = m(a,b);
end
or
function out = yourfun2(a,b)
global m;
out = m(a,b);
end
% example use function yourfun2
>> global m
>> m = randi(3,3);
>> out = yourfun2(1,2);

2 件のコメント

deepak
deepak 2012 年 10 月 22 日
while we using in c we {} for array () for function but in matlab we use same parenthesis why the developer did so
Manuel Rojas
Manuel Rojas 2020 年 8 月 8 日
This is a very big mistake

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2012 年 10 月 22 日

コメント済み:

2020 年 8 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by