フィルターのクリア

Read specific column from dat file

10 ビュー (過去 30 日間)
sci hub
sci hub 2021 年 7 月 6 日
コメント済み: sci hub 2021 年 7 月 9 日
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
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,
  7 件のコメント
Stephen23
Stephen23 2021 年 7 月 6 日
編集済み: Stephen23 2021 年 7 月 6 日
Simpler:
T = readtable('trial_1.dat.txt')
T = 5×2 table
sig olx ___ ___ 1 2 2 4 3 5 4 7 5 9
T.olx
ans = 5×1
2 4 5 7 9
sci hub
sci hub 2021 年 7 月 9 日
Thanks.. it's also working

サインインしてコメントする。

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 7 月 6 日
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 = 5×2
1 2 2 4 3 5 4 7 5 9
M(:,2)
ans = 5×1
2 4 5 7 9

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by