"Lucie Van Hove" wrote in message <firstname.lastname@example.org>... > I have a problem with fscanf, and I know it will be something stupid, but I have read all the documentation and I cannot find the solution. > > I have a textfile with this format: > aaaa > bbbb > cccc > dddd > > I want to read this in to Matlab in a vector. > But if I do > fid = fopen('file.txt','r'); > if (fid < 0) > error('could not open file "file.txt"'); > end; > A = fscanf(fid,"%s",[1,inf]) > > Then I get > A = aaaabbbbccccdddd > And that is obviously not what I want. > > Can anybody help me? Thanks
If you want it to be like a line by line try using "textscan" with delimiter option as (\n).
you get it in a cell array with each line in one cell.