Read specific column from dat file
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sci hub
el 6 de Jul. de 2021
Comentada: sci hub
el 9 de Jul. de 2021
Hi..
I am trying to read a specific colum from dat file however, the output is 1*2 cell array..
I would like the output to be [2;4;5;7;9].. I attached the file and the code as well ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/676178/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/676178/image.png)
clearvars;
clc;
close all;
fid = fopen('trial_1.dat')
data = textscan(fid, '%d %d[^\n]')
fid = fclose(fid);
% I would like data=[2;4;5;7;9]
Any help please ...
Thanks,
Respuesta aceptada
Scott MacKenzie
el 6 de Jul. de 2021
No need to use textscan. Just use readmatrix:
f = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/676208/trial_1.dat.txt';
M = readmatrix(f)
M(:,2)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!