convert the table to matrix
Mostrar comentarios más antiguos
Hi,
I used the below command and it read the dat files as a table (1x1500 cell) and each cell include (65536x4 table)
for k = 1:1500
myfilename = sprintf('Vec%05d.dat', k);
mydata{k} = readtable(myfilename);
end
then I tried to convert the table to matrix, but it doesn't work, could you please correct it to me?
for k = 1:1500
mydata1(:,:,k)= table2array(mydata{:,k})
end
my aim is to get a matrix of mydata1 with size 256x256x1500
thanks in advance
3 comentarios
madhan ravi
el 5 de Dic. de 2023
shouldn"t it be 256x256x4x1500?
Walter Roberson
el 5 de Dic. de 2023
Do you need the intermediate tables to be stored for some reason, or do you just need the final array?
Is there a reason you are using readtable() instead of readmatrix() ?
Mohamed
el 5 de Dic. de 2023
No I don't want to store the tables , I need the final array
Respuesta aceptada
Más respuestas (1)
Sulaymon Eshkabilov
el 5 de Dic. de 2023
I believe as Madhan pinpointed that you data size should be 256x256x4x1500. Here is the final code:
for k = 1:1500
myfilename = sprintf('Vec%05d.dat', k);
mydata{k} = readtable(myfilename);
mydata1(:,:,k)= table2array(mydata{:,k})
end
%% Final conversion after collecting all data from the files into an ARRAY
MY_data_OK = reshape(MY_data, [256, 256, 4, 1500]);
1 comentario
Mohamed
el 5 de Dic. de 2023
Actually, I am not sure that: mydata1(:,:,k)=table2array(mydata{:,k})
This command worked for a day without stopping. So I could you please tell me where is the mistake because I think it is just a loop
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!