How to convert large text file into individual cells into 1x408 array

3 ビュー (過去 30 日間)
Jakob Loverde
Jakob Loverde 2021 年 3 月 11 日
編集済み: Jakob Loverde 2021 年 3 月 11 日
I need to convert a large text file that I can make look like this:
00
11
22
33
...
408
or like this: 00 11 22 33 ... 408 via notepad++.
I want to take this and put it into a 1x408 so I can work with it. The array should be [00][11][22][33].
What I have tried is this:
filename = '2020_06_01_08_27_17exp2.txt';
delimiterIn = '\n';
A = importdata(filename, delimiterIn);
and also this
filename = '2020_06_01_08_27_17exp2.txt';
fileID = fopen(filename, 'r');
formatSpec = '%f';
A = fscanf(fileID, formatSpec);
fclose(fileID);

回答 (1 件)

Jakob Loverde
Jakob Loverde 2021 年 3 月 11 日
編集済み: Jakob Loverde 2021 年 3 月 11 日
filename = '2020_06_01_08_27_17exp2.txt';
fileID = fopen(filename, 'r');
formatSpec = '%x';
A = fscanf(fileID, formatSpec);
fclose(fileID);
This did it! I am reading in hex values so using %x fixed everything!

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by