how can I save a variable to an excel file?

2 ビュー (過去 30 日間)
Adnan
Adnan 2025 年 3 月 24 日
コメント済み: Star Strider 2025 年 3 月 24 日
Hi,
I have a complex variable (named "ST_normalized") in my MATLAB code. I want to save that file to an Excel file. Can you please help me with that? Thanks for your time.
regards

採用された回答

Star Strider
Star Strider 2025 年 3 月 24 日
Try something like this —
ST_normalized = complex(randn(10,1), randn(10,1))
ST_normalized =
0.1199 + 0.4231i -0.1599 - 0.8992i 0.5147 - 2.1564i -1.0715 - 1.0423i -1.4185 - 1.3712i 0.0783 + 0.8757i 1.9040 - 1.2376i -1.2342 - 0.2979i -0.6224 - 0.7768i 1.6192 - 0.1821i
writematrix([real(ST_normalized), imag(ST_normalized)], 'Test1.xlsx')
Check = readmatrix('Test1.xlsx')
Check = 10×2
0.1199 0.4231 -0.1599 -0.8992 0.5147 -2.1564 -1.0715 -1.0423 -1.4185 -1.3712 0.0783 0.8757 1.9040 -1.2376 -1.2342 -0.2979 -0.6224 -0.7768 1.6192 -0.1821
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
ST_normalized = complex(Check(:,1), Check(:,2))
ST_normalized =
0.1199 + 0.4231i -0.1599 - 0.8992i 0.5147 - 2.1564i -1.0715 - 1.0423i -1.4185 - 1.3712i 0.0783 + 0.8757i 1.9040 - 1.2376i -1.2342 - 0.2979i -0.6224 - 0.7768i 1.6192 - 0.1821i
.
  9 件のコメント
Sam Chak
Sam Chak 2025 年 3 月 24 日
@Star Strider, Thank you for demonstrating the segmentation approach. I have used the writematrix() function, although infrequently and not with datasets containing tens of thousands of entries. Therefore, this error is indeed new to me.
Error using writematrix (line 218)
The data block starting at cell 'A1' exceeds the sheet boundaries by 0 row(s) and 2199
column(s).
Star Strider
Star Strider 2025 年 3 月 24 日
@Sam Chak — My pleasure!
I had never gotten that sort of error, either. The segmentation approach seems the only way around it.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by