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 个评论
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