Is there a way in Matlab to determine the number of lines in a file without looping through each line?

后端 未结 5 1676
無奈伤痛
無奈伤痛 2020-12-05 00:57

Obviously one could loop through a file using fgetl or similar function and increment a counter, but is there a way to determine the number of lines in a file without

5条回答
  •  孤城傲影
    2020-12-05 00:59

    I would recommend using an external tool for this. For example an app called cloc, which you can download here for free.

    On linux you then simply type cloc and get

    YourPC$ cloc 
          87 text files.
          81 unique files.                              
          23 files ignored.
    
    http://cloc.sourceforge.net v 1.60  T=0.19 s (311.7 files/s, 51946.9 lines/s)
    -------------------------------------------------------------------------------
    Language                     files          blank        comment           code
    -------------------------------------------------------------------------------
    MATLAB                          59           1009           1074           4993
    HTML                             1              0              0             23
    -------------------------------------------------------------------------------
    SUM:                            60           1009           1074           5016
    -------------------------------------------------------------------------------
    

    They also claim it should work on windows.

提交回复
热议问题