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 comentario

deepak
deepak el 22 de Oct. de 2012
Editada: deepak el 22 de Oct. de 2012
send some other answers in words

Iniciar sesión para comentar.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 22 de Oct. de 2012
Editada: Andrei Bobrov el 22 de Oct. de 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 comentarios

while we using in c we {} for array () for function but in matlab we use same parenthesis why the developer did so
This is a very big mistake

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Etiquetas

Preguntada:

el 22 de Oct. de 2012

Comentada:

el 8 de Ag. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by