How to read line from a text file as a string in matlab?

file-io, matlab

Solution

`fgetl(fid)` will do what you're looking for. Newline is stripped off.

Problem

I am trying to read a text file in MATLAB which has a format like the following. I am looking to read the whole line as a string. ``` 2402:0.099061 2404:0.136546 2406:0.447161 2407:0.126333 2408:0.213803 2411:0.068189 ``` I tried couple of things. `textscan(fid, '%s')` reads the line but splits the line into cells at spaces. `fscanf(fid, '%s')` reads the line as a string but removes all the spaces.

Original source