why we use same parenthesis for function calling and array?

I
Isaiah · Dec 14, 2020 · 1.9K views
Question
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
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Nov 20, 2025
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);
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!