How to get data from file to matrix?

2 ビュー (過去 30 日間)
Edgar Rodríguez Cumplido
Edgar Rodríguez Cumplido 2019 年 3 月 12 日
Hi, I want to read a TXT file (this file has 35 columns and 351 rows) and save all the data to a matrix (35 x 351).
I'm trying with the following code:
formatSpec = '%d';
sizeA = [351 35];
A = fscanf(fileID,formatSpec,sizeA);
It creates the matrix (35 x 351) and saves the data, but no propperly.
What I want is, for example, read the first line of the TXT, then storage that line in the first row of the matrix.
Thanks

採用された回答

dpb
dpb 2019 年 3 月 13 日
>> A=importdata('ionos.txt');
>> whos A
Name Size Bytes Class Attributes
A 351x35 98280 double
>> A(1:5,1:10) % see what a little bit of it looks like...
ans =
49 0 49 23 46 25 45 15 49 25
49 0 49 20 48 15 22 1 49 23
49 0 49 24 49 25 49 21 47 25
49 0 49 13 49 49 42 0 25 25
49 0 49 24 48 26 48 19 44 20
>>
  1 件のコメント
Edgar Rodríguez Cumplido
Edgar Rodríguez Cumplido 2019 年 3 月 13 日
Thanks for your answer!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by