execute cell content as lines of command in Matlab

조회 수: 1(최근 30일)
Hamid
Hamid 2022년 1월 26일
댓글: Hamid 2022년 2월 3일
I have a cell that cintains execution command such as
A{1} = python run_my_code -m var1="1" var2 ="2"
A{2} = python run_my_code -m var1="2" var2 ="4"
...
When I use system(A{1}) it gives me sytax error.
The idea is to run all cell contetnts in a for loop within matlab.
Any help is appreciated
  댓글 수: 3
DGM
DGM 2022년 1월 28일
I am not familiar with python, but if the errors are with python instead of matlab, then environment configuration sounds like something worth looking into.

댓글을 달려면 로그인하십시오.

답변(1개)

Yongjian Feng
Yongjian Feng 2022년 1월 29일
Try this first from matlab command line window:
pe = pyenv
This will tell you what python env is used by your matlab installation.
  댓글 수: 1
Hamid
Hamid 2022년 2월 3일
Thanks for the suggestion Yongjian Feng. I found setting the conda environment difficult for different operating systems as I am working withing different platforms. The easiest way for me was to set the environment in Terminal.
  1. 'conda activate envx'
  2. bring up Matlab from terminal (instead of shortcut)
  3. run the matlab script within which the system(A{1}) is set to call and run Python.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by