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.

 채택된 답변

Matt Fig
Matt Fig 2011년 4월 3일

0 개 추천

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

질문:

2011년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by