Matlab system call

I see that you found a solution, let me give you a bit more elegant one, which will make life easier for the future.

system(sprintf('./util/filtermapq.sh %s %s %s', var1, var2, var3))

This could also pass in numbers, for instance, or other cool stuff. Also, you could do this to help with debugging such issues.

command=sprintf('./util/filtermapq.sh %s %s %s',var1, var2, var3);
fprintf('%s\n',command);
system(command);

That will log out to the screen the exact command that you are attempting to run. If your system command doesn't work, copy/paste it into a command line window, see if it works there. If it doesn't figure out how to massage the text to make it work, and fix your code appropriately.


I figured out the problem in my line of code. The problem was that matlab was not interpreting spaces between the variables I was inputting and was instead stringing them all together in one large string. Where my script takes 3 variables. I hope this helps anyone in the future, the correct code is as below:

system(['./util/filtermapq.sh ' var1 ' ' var2 ' ' var3])

Tags:

Matlab

Bash