Error while using writematrix to save complex values in a .txt
Mostra commenti meno recenti
Hello, I have a very basic script that reads in around 15000 complex values from a .csv file, does some basic data manipulation and saves it into a .txt file using writematrix. However, it seems the values with a negative imaginary component (i.e. in the form of a-bi) are being saved into the .txt as a+-bi. Calling a readmatrix on this file saves these values as NaN and I cannot proceed. Any ideas? A segment of the code follows along with the exported file values.
%% 1. .csv file to table to array
%% 2-4: Modify values by basic division, rss, etc
%% 5. Export data
writematrix(signal_d_prime, 'signal_modified.txt', 'Delimiter', ' ')
%% Check
readmatrix('signal_modified.txt')

Risposta accettata
Più risposte (1)
Kristijan
il 25 Set 2024
0 voti
I had the same problem with strange negitiated imaginary values. The writematrix function seems the work , but if you put an transpose a complex vector the imaginary part gets negotiated. The result is then saved with this reverted imaginary value. For example complex vector xvec. When u save the with writematrix(xvec',"matrix.txt") the stored values have negative complex entries.
1 Commento
marmite
il 24 Mar 2025
The single quotation mark operator actually does a conjugate transpose, so your observed behaviour is expected.
Categorie
Scopri di più su Text Files in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!