MATLAB: Could someone please explain to me how to take characters from a text file and put it in MATLAB

cell arraycharactersfscanfsscanftext file

So I've tried using fscanf and sscanf to take a group of words and numbers and put them into a cell array. An example of what I want in the array is "Wind data AA0, #2". I am new to MATLAB, so I've had problems getting the words I see in my text file to MATLAB using the right code. Could someone give me an example of how this is done? My attempt:
>> fileid = fopen('myfile.txt');
>> a = fscanf(fileid,'%g %g',[35 inf]) % I need only to row 35 % don't understand "%g" part
>> a = a'; % I saw that I might need to transpose it
>> fclose(fid)

Best Answer

This code will read in the whole file (well, it works on your sample file):
fid = fopen('MLsensLiftStartexample.txt','rt');
hdr = fgetl(fid);
txt = fgetl(fid);
pos = ftell(fid);
N = numel(regexp(fgetl(fid),'[^\t]+','match'));
fmt = repmat('%s',1,N);
fseek(fid,pos,'bof');
C = textscan(fid,fmt,'Delimiter','\t');
fclose(fid);
C = horzcat(C{:});
N = str2double(C);
Have a look at the variable C: all of the data is there, and the equivalent numeric in N (where appropriate).
Related Question