Prev: How to interpolate the coordinates of a vector on an image usingmatlab?
Next: Circular or polar plots in matlab problem..
From: Matteo on 1 Mar 2010 14:36 dpb <none(a)non.net> wrote in message <hmh46l$rqu$1(a)news.eternal-september.org>... > > My guess is that you're not accounting that the file pointer isn't moved > from one call to textscan to the next so you're skipping lines from the > last location read rather than from the first this way. > > Why not simply read each group the same way since it appears that's regular? > > -- Hey, great point, thank you. I unerstand what you are saying - that's big help - looks like I did not understand well how textscan operates. So pointer stays where it was left at end of previous call? I tried this quick test fid=fopen('test.txt'); for k=1:2 test(:,:,k)=textscan(fid,'%f32',501,'headerlines',1); end This gets me closer but the second matrix in the cell is still empty.... test(:,:,1) = [501x1 single] test(:,:,2) = [0x1 single]
From: dpb on 1 Mar 2010 15:21 Matteo wrote: > > dpb <none(a)non.net> wrote in message > <hmh46l$rqu$1(a)news.eternal-september.org>... >> >> My guess is that you're not accounting that the file pointer isn't >> moved from one call to textscan to the next so you're skipping lines >> from the last location read rather than from the first this way. >> >> Why not simply read each group the same way since it appears that's >> regular? >> >> -- > > Hey, great point, thank you. I unerstand what you are saying - that's > big help - looks like I did not understand well how textscan operates. > So pointer stays where it was left at end of previous call? > > I tried this quick test > fid=fopen('test.txt'); > for k=1:2 > test(:,:,k)=textscan(fid,'%f32',501,'headerlines',1); > end > > This gets me closer but the second matrix in the cell is still empty.... > > test(:,:,1) = > [501x1 single] > > > test(:,:,2) = > [0x1 single] Sorry, I can't test here as textscan() postdates the version I have... You might try adding the optional second return argument 'position' that you could see how far it got both after first and last calls. Particularly the first and inspection of the file might indicate something useful. There don't appear to be any error messages, unfortunately. --
From: dpb on 1 Mar 2010 19:51
dpb wrote: .... > You might try adding the optional second return argument 'position' that > you could see how far it got both after first and last calls. > Particularly the first and inspection of the file might indicate > something useful. There don't appear to be any error messages, > unfortunately. Specifically, I'm wondering where it left the file pointer at completion of the first (apparently successful) read and the existence of newline, etc., in the file at that point and where it failed subsequently. -- |