how can I save a variable to an excel file?

조회 수: 8 (최근 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 CenterFile Exchange에서 Data 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