Matlab: Working with files
Writing filesTo write a new file, use the function: fid= fopen(‘<filename>’, ‘wt’);To write to a new file, use the function:fprintf(fid, ‘Hello, I am writing this into the file’);
Writing filesUse the following set of commands to create a new file and write a sentence into that file. View the file in notepad.
Writing files
Writing filesTo open a file in text mode, specify the permission using one of the listed Permission Value, and attach the letter 't'. For example, use 'rt' or 'wt+'.
Reading FilesUse the command ‘fopen(‘<filename>, rt’) to open a file to be read in text mode. Use the fscanf(fid, format, size)command to read form the file.
Reading Files
Reading Files
Shifting and Sorting matricesShift and Sort Functionscircshift	Circularly shift matrix contents.sortSort array elements in ascending or descending order.sortrows	Sort rows in ascending order.issorted	Determine if matrix elements are in sorted order.
Shifting and Sorting matrices
Visit more self help tutorialsPick a tutorial of your choice and browse through it at your own pace.The tutorials section is free, self-guiding and will not involve any additional support.Visit us at www.dataminingtools.net

Matlab Text Files

  • 1.
  • 2.
    Writing filesTo writea new file, use the function: fid= fopen(‘<filename>’, ‘wt’);To write to a new file, use the function:fprintf(fid, ‘Hello, I am writing this into the file’);
  • 3.
    Writing filesUse thefollowing set of commands to create a new file and write a sentence into that file. View the file in notepad.
  • 4.
  • 5.
    Writing filesTo opena file in text mode, specify the permission using one of the listed Permission Value, and attach the letter 't'. For example, use 'rt' or 'wt+'.
  • 6.
    Reading FilesUse thecommand ‘fopen(‘<filename>, rt’) to open a file to be read in text mode. Use the fscanf(fid, format, size)command to read form the file.
  • 7.
  • 8.
  • 9.
    Shifting and SortingmatricesShift and Sort Functionscircshift Circularly shift matrix contents.sortSort array elements in ascending or descending order.sortrows Sort rows in ascending order.issorted Determine if matrix elements are in sorted order.
  • 10.
  • 11.
    Visit more selfhelp tutorialsPick a tutorial of your choice and browse through it at your own pace.The tutorials section is free, self-guiding and will not involve any additional support.Visit us at www.dataminingtools.net