Escape characters in Matlab

前端 未结 2 653
野趣味
野趣味 2021-01-21 14:30

I am reading a file using fileread() which returns me the entire file. Now I need to read line by line and convert them into process the data. Can I know how I would be able to

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-21 14:44

    You can read the file line by line (see fgetl):

    fid = fopen ( 'file', 'r' );
    % Check that it opened okay
    if fid ~= -1
      while ( true )
        line = fgetl ( fid );
        % Check for end of file
        if line == -1; break; end
        %Do stuff with line;
      end
      fclose ( fid );
    end
    

提交回复
热议问题