from python to matlab

조회 수: 3 (최근 30일)
qrqr
qrqr 2019년 8월 1일
답변: Loretta Laughrey 2020년 5월 20일
I do not know how to send variables defined in python to MATLAB.
If you define A = 2 in python,
how does A = 2 in the MATLAB workspace Can you move it?
  댓글 수: 2
KSSV
KSSV 2019년 8월 1일
In matlab simple:
A = 2
qrqr
qrqr 2019년 8월 1일
I want to move python variables to MATLAB

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

채택된 답변

Wiley Mosley
Wiley Mosley 2019년 8월 2일
편집: Wiley Mosley 2019년 8월 2일
I believe you would want to utilize the matlab engine. If you are just trying to get the data in a format that you can then call a matlab function there are examples in the above link that should help you out.
You could possibly try sharing the session and maybe then variables in python would appear in the matlab workspace, but I have not tried this before.
  댓글 수: 1
qrqr
qrqr 2019년 8월 2일
Thanks
I entered the following code
cd (fullfile(matlabroot,'extern','engines','python'))
system('python setup.py install')
But,I got the following error
'python' is an internal or external command,
It is not recognized as an operable program or batch file.
Each version is below
MATLAB Ver.2019a
Python Ver.2.7

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

추가 답변 (2개)

Wiley Mosley
Wiley Mosley 2019년 8월 1일
  댓글 수: 1
qrqr
qrqr 2019년 8월 2일
Thank you
I saw the contents
Pass data from Python to MATLAB
It is written like this, but I do not know because there is no concrete code.
For example, typing 'float' will do something?

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


Loretta Laughrey
Loretta Laughrey 2020년 5월 20일
Just pass the variable in a function call:
In Python:
eng = matlab.engine.start_matlab("-desktop")
eng.cd(myscripts, nargout=0) # change to the folder with the scripts
results = eng.mymatlabscript(self.A, self.B, nargout = 0, async = False)
In MATLAB
function mymatlabscript(A, B)

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by