How can I read a complex number vector?
이전 댓글 표시
Hi, I have this problem. I'm trying to read a complex number vector from a txt file using this structure:
fid=fopen ('VarName4.txt','r');
acorrente=fscanf(fid,'%f');
fclose (fid);
VarName4.txt is a vector 1000x1 like this:
[0.0141451080390089-0.00224036502008852i
0.0141451080390089-0.00224036502008852i
0.0141451080390089-0.00224036502008852i
0.0141451080390089-0.00224036502008852i...]
Using the structure before, the answer is:
acorrente =
0.0141
-0.0022
Why it doesn't work? Could someone teach me? Thanks a lot!
댓글 수: 2
José-Luis
2014년 2월 11일
It doesn't work because you are telling fscanf to expect a floating point number. Fscanf won't read in imaginary numbers.
André Luiz Regis Monteiro
2014년 2월 11일
채택된 답변
추가 답변 (1개)
Use dlmread or textscan https://stackoverflow.com/questions/20538049/reading-complex-data-in-matlab-from-a-file
카테고리
도움말 센터 및 File Exchange에서 Low-Level File I/O에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!