How to call one program from another in MATLAB?

I have to call a program/ module from another. If possible please give an example. Say, there's a program which sends integers from 1 to 10 to another program, and the other program adds 2 to each integer that it gets and prints it.

 Accepted Answer

Save this first function in one M-file (copy and paste it, then save it):
function [] = receives_integers()
% Prints integers it gets.
INT = sends_integers; % Call the other function.
for ii = 1:length(INT)
disp(INT(ii)+2)
end
And then save this next function to another, separate M-file:
function INT = sends_integers()
% Sends 1 through 10.
INT = 1:10;
Now from the command line, type this and hit return:
receives_integers

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!