필터 지우기
필터 지우기

How to import data from a txt file that has 256 arrays and 128 data points per array into a 128x256 matrix?

조회 수: 1 (최근 30일)
I have data in a txt file that I would like to import into Matlab for further analysis.
The file has val(:,:,1), val(:,:,2), and so on all the way to val(:,:.256) and each array contains 128 data points.
I want to import these data so that it’s in a 128x256 (column x row) matrix.
The first line of all the arrays contain a scientific notation that must be multiplied by the following cells in that array.
For example, the frst line of val(:,:,256) is 1.0e-08 * followed by 128 data points.
I tried using the load command and it outputs an error message.
I also tried using importdata, which isn’t working either.
What can I do to import this data into a 128x256 matrix? (Please see attached for the txt file).
  댓글 수: 1
C B
C B 2021년 10월 11일
val(:,:,1) =[...
...
1.0e0 *...
...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i]...
val(:,:,2) =[...
...
1.0e0 *...
...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i...
0.0000 + 0.0000i]...

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

채택된 답변

KSSV
KSSV 2021년 10월 11일
편집: KSSV 2021년 10월 11일
filename = 'SeqLoop.data.kSpaceOS.txt' ;
fid = fopen(filename,'r') ;
S = textscan(fid,'%s','delimiter','\n') ;
fclose(fid) ;
S = S{1} ;
S = str2double(S) ;
idx = isnan(S) ;
S = S(~idx) ;
S = reshape(S,128,[]) ;
  댓글 수: 3
KSSV
KSSV 2021년 10월 11일
Yes you are right...I forgot to add that line. Now edited the answer.
parslee
parslee 2021년 11월 15일
The first line of all the arrays contain a scientific notation that must be multiplied by the following cells in that array.
How can I implement this in the coding?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by