Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: textscan with precision random NaN
Replies: 3   Last Post: Jun 24, 2013 12:01 PM

 Messages: [ Previous | Next ]
 Nathaniel Posts: 2 Registered: 6/24/13
Re: textscan with precision random NaN
Posted: Jun 24, 2013 11:45 AM

"someone" wrote in message <kq9o1b\$29a\$1@newscl01ah.mathworks.com>...
> "Nathaniel" wrote in message <kq9lo8\$oja\$1@newscl01ah.mathworks.com>...
> > I am reading in a set of data using the textscan function. This was working perfectly ... until I added precision. Now it reads in all the data correctly, but also reads in NaN values between some of the lines. So, if the data were:
> > 1
> > 2
> > 3
> > 4
> > 5
> >
> > it might be read in as
> >
> > 1
> > 2
> > 3
> > NaN
> > 4
> > NaN
> > 5
> >
> > Still investigating if there is a pattern in the NaN placement, but does anyone have any leads? Thank you for your time.

>
> Based on the information you provided, its going to take a lot of guessing to give you any kind of an answer.
>
> Can you provide sniplets of your code befor and after?
> What does the input data look like?
> How did you "add precision" to textscan?

Good point, sorry, this is my first time on a forum.
I'm using this for text scan

fid = fopen(DataPath{1});
data = textscan(fid, '%d64 %s %*s %*f %*f %*f %*f %*f %.15f %.15f', 'Delimiter', '\t', 'headerlines', 1);
structData= cell2struct(data, {'Points', 'Person', 'Allocation','SD'}, 2);

Before adding in the .15 I would be reading in 2880ish lines but after adding it in I'm reading in 3400ish - the difference being made up of NaN

Input data is an edr.txt file

Date Subject Author
6/24/13 Nathaniel
6/24/13 Curious
6/24/13 Nathaniel
6/24/13 dpb