Importing dat files as a double matrix

14 visualizaciones (últimos 30 días)
Mohamed
Mohamed el 4 de Dic. de 2023
Comentada: Stephen23 el 7 de Dic. de 2023
I am new in matlab, and I got data stored as dat files and I need to import them as a double matrix
Thanks in advance
Mohamed
  3 comentarios
Mario
Mario el 4 de Dic. de 2023
I tried to upload one of the files, but the website site refused as they don't support Dat files. I got a set of dat files and they were generated from another Matlab function. each file contains 4 columns (X,Y,U,V)
Voss
Voss el 4 de Dic. de 2023
You can zip the dat file(s) and upload the zip file.

Iniciar sesión para comentar.

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 4 de Dic. de 2023
Editada: KALYAN ACHARJYA el 4 de Dic. de 2023
Example
#Edited (Pls Check Comments)
data = readmatrix('yourfile.dat');
data = double(importdata('yourfile.dat'));
  6 comentarios
Mario
Mario el 5 de Dic. de 2023
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
Stephen23
Stephen23 el 7 de Dic. de 2023
P = 'absolute or relative path to where the files are saved';
N = 1500;
C = cell(1,N);
for k = 1:N
F = sprintf('Vec%05d.dat',k);
C{k} = readmatrix(fullfile(P,F));
end
A = cat(3,C{:});

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by