why we use same parenthesis for function calling and array?

3 vues (au cours des 30 derniers jours)
deepak
deepak le 22 Oct 2012
Commenté : Manuel Rojas le 8 Août 2020
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 commentaire
deepak
deepak le 22 Oct 2012
Modifié(e) : deepak le 22 Oct 2012
send some other answers in words

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 22 Oct 2012
Modifié(e) : Andrei Bobrov le 22 Oct 2012
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 commentaires
deepak
deepak le 22 Oct 2012
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 le 8 Août 2020
This is a very big mistake

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by