I just want to call two matlab commands from Python: the fist command just adds the folder and subfolders fo the desired path ( addpath(genpath('c:/file1/file2'))
), while the second command calls the function I want to use ( myfunction.m
).
I always used os.system("command")
when I needed to call a function and os.system("command1 | command2")
when I wanted to call two functions for example, so I tried:
os.system("matlab -r addpath(genpath('c:/file1/file2')) | matlab -r myfunction")
But obviously this opens two matlab windows, the first one for the fist command and the second one for the second command. What I want is to call both commands in the same window, one after the other. However, if I try simply:
os.system("matlab -r addpath(genpath('c:/file1/file2')) -r myfunction")
it doesn't work...It performs the first command ( addpath
) but it does not call the function....
What I am doing wrong?? Any idea about how to do that?? I read lot of posts but they weren't very helpful, even if this is a very simple case.
Thanks in advance guys!! I really appreciate your help