Convert Matlab Cell-Array with subtables into a python variable type

4 ビュー (過去 30 日間)
MatlabUser
MatlabUser 2023 年 4 月 26 日
編集済み: MatlabUser 2023 年 4 月 28 日
Hello community,
I have a cell-array "signal" that I want to transfer to Python. Have someone an idea of which data format is therefore most appropriate and how I can manage the transfer?
sig1 = rand(20,1);
sig2 = rand(20,1);
sig3 = rand(20,1);
sig4 = rand(20,1);
tab1 = table(sig1, sig2);
tab2 = table(sig3, sig4, 'VariableNames', ["sig1", "sig2"]);
signal = {tab1, tab2};
signal(2,:) = signal;
signal{3,1} = "String1";
signal{3,2} = "String2";
Greetings

回答 (1 件)

chicken vector
chicken vector 2023 年 4 月 26 日
I do not know specifically how to pass data from Matlab to Python, but my way of doing it would be to store the cell in Excell sheets with writematrix and/or writecell, and use pandas in Excell to retrieve the data.
  1 件のコメント
MatlabUser
MatlabUser 2023 年 4 月 26 日
編集済み: MatlabUser 2023 年 4 月 28 日
Thank you, I have now solved it with Python, i.e. saved it in Matlab as .mat and then loaded it into Python. See also https://www.blogforbrains.com/blog/2014/9/6/loading-matlab-mat-data-in-python
EDIT: But of course I am still open for further ideas :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by