mttReadFile.m 523 B

123456789101112131415161718192021222324
  1. function content = mttReadFile(filename)
  2. file_exists = exist(filename)==2 ;
  3. if file_exists
  4. fid = fopen(filename,'r') ;
  5. reading = 1 ;
  6. counter = 0 ;
  7. while reading
  8. line = fgetl(fid) ;
  9. if ~isempty(line)
  10. if line==-1
  11. reading = 0 ;
  12. else
  13. counter = counter + 1 ;
  14. content{counter} = line ;
  15. end
  16. end
  17. end
  18. fclose(fid) ;
  19. else
  20. error(['file_not_found[',filename,']'])
  21. end