Running a Python Script with multiple inputs and outputs through Matlab

조회 수: 14 (최근 30일)
Hallo, i have a pytho script with 10 inputs and 5 outputs and the on of the outputs is a list. I want to run this script throught matlab and give my inputs in matlab and then receive the outputs from Python in Matlab. Is that possible? I have tried some things, but i could redirect only one output from python to matlab. I am open to suggestion :)

채택된 답변

Yongjian Feng
Yongjian Feng 2021년 8월 21일
One interesting trick is to use json. From python, serialize all the outputs into one single json string. In matlab, convert the json string back to json.
  댓글 수: 2
Constantinos Florides
Constantinos Florides 2021년 8월 28일
편집: Constantinos Florides 2021년 8월 28일
That is a very interesting idea!Is there a reason to pass from python a json string and not direct make a json file?
Yongjian Feng
Yongjian Feng 2021년 8월 29일
Yes, you can do it with a json file as well. But then you need to write and read the file. Also if you write to a file, it doesn't need to be json.

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

추가 답변 (1개)

Rhea Chandy
Rhea Chandy 2021년 8월 23일
Hello Constantinos,
I understand that you're trying to run python script in MATLAB and then recieve outputs from Python in MATLAB.
Along with the above answer, you can also take a look at this previously answered question: Running python script in matlab
You will find the following resources with more information and examples here:
  댓글 수: 1
Constantinos Florides
Constantinos Florides 2021년 8월 28일
Yeap, i am trying to run a python script throught Matlab, i have seen these topics. They were very useful. The only part that i need to solve is to pass my outputs with json file to matlab:)

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

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by