Converting numpy arrays in python to .mat in matlab

조회 수: 675 (최근 30일)
Karthika Krishna
Karthika Krishna 2020년 10월 21일
답변: abraham rodriguez 2021년 9월 18일
I have a 2D numpy array in python and I want to image this array in matlab using 'imagesc()'. I was trying to convert the array to Pandas DataFrame and then to export it as .csv file so that I can load it in matlab. But I feel there is an easier way than this. Ultimately what I want is to convert my python array to matlab matrix.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 21일
편집: Ameer Hamza 2020년 10월 21일
You can directly save to a .mat file using savemat() from scipy: https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.savemat.html
Alternatively, you can also read about calling python functions from MATLAB: https://www.mathworks.com/help/matlab/call-python-libraries.html
  댓글 수: 2
Karthika Krishna
Karthika Krishna 2020년 10월 21일
Thanks a lot. It worked.
Ameer Hamza
Ameer Hamza 2020년 10월 21일
I am glad to be of help!

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

추가 답변 (1개)

abraham rodriguez
abraham rodriguez 2021년 9월 18일
In latest R2021a, you can pass a python numpy ndarray to double() and it will convert to a native matlab matrix, even when calling in console the numpy array it will suggest at the bottom "Use double function to convert to a MATLAB array"

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by