<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239785</link>
    <title>MATLAB Central Newsreader - Omitting certain lines with 'textscan'</title>
    <description>Feed for thread: Omitting certain lines with 'textscan'</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 23 Nov 2008 19:32:01 -0500</pubDate>
      <title>Omitting certain lines with 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239785#612739</link>
      <author>Ryan Utz</author>
      <description>Hi all,&lt;br&gt;
&lt;br&gt;
I'm trying to import a very basic data set that looks like this:&lt;br&gt;
&lt;br&gt;
year month day hour flow&lt;br&gt;
1992 2 13 6 18.3&lt;br&gt;
&lt;br&gt;
Sometimes, however, when the data are erroneous the final field (flow) is listed as a negative number. I'd like to just omit any and all data when this is the case, in other words, I don't even want the dates for erroneous data to be imported. Is there a clean way in 'textscan' to specify when to ignore a particular line when it involves just one field? If not, anyone have any post-import ideas?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Ryan</description>
    </item>
    <item>
      <pubDate>Sun, 23 Nov 2008 20:06:06 -0500</pubDate>
      <title>Re: Omitting certain lines with 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239785#612744</link>
      <author>NZTideMan</author>
      <description>On Nov 24, 8:32=A0am, &quot;Ryan Utz&quot; &amp;lt;r...@al.umces.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi all,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I'm trying to import a very basic data set that looks like this:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; year month day hour flow&lt;br&gt;
&amp;gt; 1992 2 13 6 18.3&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Sometimes, however, when the data are erroneous the final field (flow) is=&lt;br&gt;
&amp;nbsp;listed as a negative number. I'd like to just omit any and all data when t=&lt;br&gt;
his is the case, in other words, I don't even want the dates for erroneous =&lt;br&gt;
data to be imported. Is there a clean way in 'textscan' to specify when to =&lt;br&gt;
ignore a particular line when it involves just one field? If not, anyone ha=&lt;br&gt;
ve any post-import ideas?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; Ryan&lt;br&gt;
&lt;br&gt;
Think about it.&lt;br&gt;
How would textscan (or any routine) know if the number was negative&lt;br&gt;
unless it read it in?&lt;br&gt;
The best way is to read everything in, then post process the data by&lt;br&gt;
finding the addresses of the negative flows:&lt;br&gt;
indx=3DQ&amp;lt;0;&lt;br&gt;
or&lt;br&gt;
indx=3Dfind(Q&amp;lt;0);&lt;br&gt;
Then you can eliminate those rows:&lt;br&gt;
Q(indx)=3D[];&lt;br&gt;
year(indx)=3D[];&lt;br&gt;
etc</description>
    </item>
    <item>
      <pubDate>Sun, 23 Nov 2008 20:07:10 -0500</pubDate>
      <title>Re: Omitting certain lines with 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239785#612745</link>
      <author>Walter Roberson</author>
      <description>Ryan Utz wrote:&lt;br&gt;
&amp;gt; Sometimes, however, when the data are erroneous the final field (flow) is listed as&lt;br&gt;
&amp;gt; a negative number. I'd like to just omit any and all data when this is the case,&lt;br&gt;
&amp;gt; in other words, I don't even want the dates for erroneous data to be imported. Is there&lt;br&gt;
&amp;gt; a clean way in 'textscan' to specify when to ignore a particular line when it involves&lt;br&gt;
&amp;gt; just one field?&lt;br&gt;
&lt;br&gt;
Sorry, no.&lt;br&gt;
&lt;br&gt;
&amp;gt; If not, anyone have any post-import ideas?&lt;br&gt;
&lt;br&gt;
A(A(:,end) &amp;lt; 0),:) = [];&lt;br&gt;
&lt;br&gt;
The above will delete all rows of A in which the last column is less than 0.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
.signature note: I am now avoiding replying to unclear or ambiguous postings.&lt;br&gt;
Please review questions before posting them. Be specific. Use examples of what you mean,&lt;br&gt;
of what you don't mean. Specify boundary conditions, and data classes and value&lt;br&gt;
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?</description>
    </item>
    <item>
      <pubDate>Sun, 23 Nov 2008 20:09:02 -0500</pubDate>
      <title>Re: Omitting certain lines with 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239785#612746</link>
      <author>Andres </author>
      <description>&quot;Ryan Utz&quot; &amp;lt;rutz@al.umces.edu&amp;gt; wrote in message &amp;lt;ggcb3h$k5k$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm trying to import a very basic data set that looks like this:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; year month day hour flow&lt;br&gt;
&amp;gt; 1992 2 13 6 18.3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Sometimes, however, when the data are erroneous the final field (flow) is listed as a negative number. I'd like to just omit any and all data when this is the case, in other words, I don't even want the dates for erroneous data to be imported. Is there a clean way in 'textscan' to specify when to ignore a particular line when it involves just one field? If not, anyone have any post-import ideas?&lt;br&gt;
&lt;br&gt;
It looks much easier to me to follow the post-import route...&lt;br&gt;
as an example:&lt;br&gt;
a = [1 2 3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4 5 -6&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7 8 9];&lt;br&gt;
isOk = a(:,end)&amp;gt;=0;&lt;br&gt;
b = a(isOk,:);</description>
    </item>
    <item>
      <pubDate>Sun, 23 Nov 2008 20:16:01 -0500</pubDate>
      <title>Re: Omitting certain lines with 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239785#612749</link>
      <author>Andres </author>
      <description>Hey, why is everbody repying at the same instant?&lt;br&gt;
Ok, I was the last, I'll by a round and log out.&lt;br&gt;
Bye&lt;br&gt;
A.</description>
    </item>
    <item>
      <pubDate>Sun, 23 Nov 2008 23:27:02 -0500</pubDate>
      <title>Re: Omitting certain lines with 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239785#612766</link>
      <author>Ryan Utz</author>
      <description>Thanks everyone-this solution works great! This newsgroup is a life-saver.&lt;br&gt;
&lt;br&gt;
Ryan</description>
    </item>
  </channel>
</rss>

