why we use same parenthesis for function calling and array?
5 views (last 30 days)
Show older comments
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
Accepted Answer
Andrei Bobrov
on 22 Oct 2012
Edited: Andrei Bobrov
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!