Error while using writematrix to save complex values in a .txt

조회 수: 4 (최근 30일)
Ragini Bakshi
Ragini Bakshi 2019년 12월 4일
댓글: marmite 2025년 3월 24일
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')
signal mod.JPG

채택된 답변

Jeremy
Jeremy 2019년 12월 4일
편집: Jeremy 2019년 12월 4일
csvwrite
Does this correctly. I will look into writematrix
  댓글 수: 4
Jeremy
Jeremy 2021년 5월 26일
편집: Jeremy 2021년 5월 26일
What version of MATLAB are you using? The issue with writematrix described in this post was fixed in R2020b. If you are using an older version I would recommend updating. If you are using a recent version and still running into an issue I would recommend making a separate question post.
XYC
XYC 2022년 1월 9일
Hello Jeremy, I have the same problem when I call writematrix to write the matrix into a txt file and I use R2021a, any solution to this?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Kristijan
Kristijan 2024년 9월 25일
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
marmite
marmite 2025년 3월 24일
The single quotation mark operator actually does a conjugate transpose, so your observed behaviour is expected.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by