To write to a file in Matlab, use the fopen function to open a file with write permission and the fprintf function to write text to the file. To read from a file, use the fopen function to open the file with read permission and the fscanf function to read data from the file. Matlab has functions like circshift to circularly shift matrix elements, sort to sort arrays in ascending or descending order, and issorted to check if elements are already sorted.