Based on the not-working, but well thought, idea of @Ilya Kobelevskiy here the final workaround:
function pipeConnection(numIterations,inputFile)
for i=1:numIterations
while(exist('inputfile','file'))
load inputfile;
% read inputfile -> inputdata
output = myFunction(inputdata);
delete('inputfile');
end
% Write output to file
% Call external application to process output data
% generate new inputfile
end;
Another convenient solution would be to compile an executable of the Matlab function:
mcc -m myfunction
run this .exe
-file using cmd
:
cd myCurrentDirectory && myfunction.exe parameter1 parameter2
Be aware that the parameters are now passed as strings and the original .m
-file needs to be adjusted considering that.
further remarks:
- I guess Matlab still needs to be installed on the system, though it is not necessary to run it.
- I don't know how far this method is limited respectively the complexity of the underlying function.
- The speed-up compared to the initial apporach given in the question is relatively small