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

1 view (last 30 days)
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 Comment
C B
C B on 11 Oct 2021
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]...

Sign in to comment.

Accepted Answer

KSSV
KSSV on 11 Oct 2021
Edited: KSSV on 11 Oct 2021
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 Comments
parslee
parslee on 15 Nov 2021
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?

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!