how to read a matrix from a text file in matlab

前端 未结 4 1704
半阙折子戏
半阙折子戏 2021-01-15 08:51

I have a text file which has 500 columns and 500 rows, of numerical(integer) values . Every element in the row is separated by a tab. I want to rea

4条回答
  •  孤独总比滥情好
    2021-01-15 09:12

    You can use importdata. Something like:

    filename = 'myfile01.txt';
    delimiterIn = '\t';
    headerlinesIn = 1;
    A = importdata(filename,delimiterIn,headerlinesIn);
    A_trans = A';
    

    You can skip headerlines if your file does not have any haeder.. (It is the number of lines before the actual data starts)

    Taken from Matlab documentation, improtdata

提交回复
热议问题