Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commento
C B
C B il 11 Ott 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]...

Accedi per commentare.

Risposta accettata

KSSV
KSSV il 11 Ott 2021
Modificato: KSSV il 11 Ott 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 Commenti
parslee
parslee il 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?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by