how can I save a variable to an excel file?

8 visualizaciones (últimos 30 días)
Adnan
Adnan el 24 de Mzo. de 2025
Comentada: Star Strider el 24 de Mzo. de 2025
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

Respuesta aceptada

Star Strider
Star Strider el 24 de Mzo. de 2025
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 comentarios
Sam Chak
Sam Chak el 24 de Mzo. de 2025
@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 el 24 de Mzo. de 2025
@Sam Chak — My pleasure!
I had never gotten that sort of error, either. The segmentation approach seems the only way around it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by