<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237003</link>
    <title>MATLAB Central Newsreader - reading a data file to searches on Date</title>
    <description>Feed for thread: reading a data file to searches on Date</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>Sat, 04 Oct 2008 13:27:01 -0400</pubDate>
      <title>reading a data file to searches on Date</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237003#603685</link>
      <author>John Smith</author>
      <description>Hi,&lt;br&gt;
&amp;nbsp;I wanted to read in a file with the following format&lt;br&gt;
&lt;br&gt;
Date  number number &lt;br&gt;
&lt;br&gt;
where date is a string such as &quot;4-Oct-08&quot; and numbers are floating point.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;I want to be able to do some searches (using find) on the Date. How do I read in the file such that I can do the searches on the date ?&lt;br&gt;
&lt;br&gt;
&amp;nbsp;Many thanks.&lt;br&gt;
&lt;br&gt;
John.</description>
    </item>
    <item>
      <pubDate>Sat, 04 Oct 2008 19:40:04 -0400</pubDate>
      <title>reading a data file to searches on Date</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237003#603710</link>
      <author>Andres </author>
      <description>&quot;John Smith&quot; &amp;lt;cc200802@yahoo.com&amp;gt; wrote in message &amp;lt;gc7qv5$pv0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;  I wanted to read in a file with the following format&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Date  number number &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; where date is a string such as &quot;4-Oct-08&quot; and numbers are floating point.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  I want to be able to do some searches (using find) on the Date. How do I read in the file such that I can do the searches on the date ?&lt;br&gt;
&lt;br&gt;
Hi John,&lt;br&gt;
use textscan to read in the data, i.e. something like&lt;br&gt;
&lt;br&gt;
fname = 'c:\jsmith.txt';&lt;br&gt;
fid = fopen(fname);&lt;br&gt;
A = textscan(fid, '%s %f %f');&lt;br&gt;
fclose(fid);&lt;br&gt;
&lt;br&gt;
and if necessary apply one of the date functions (like datevec) to the first element of A (which stores the date strings in a cell array of strings). The respective doc pages will give you more insight into this.&lt;br&gt;
I hope this gets you started.&lt;br&gt;
Regards&lt;br&gt;
Andres</description>
    </item>
    <item>
      <pubDate>Sun, 05 Oct 2008 14:28:01 -0400</pubDate>
      <title>reading a data file to searches on Date</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237003#603780</link>
      <author>John Smith</author>
      <description>Hi Andres,&lt;br&gt;
Thank you very much.&lt;br&gt;
&lt;br&gt;
John&lt;br&gt;
&lt;br&gt;
&quot;Andres &quot; &amp;lt;rantore@werb.deNoRs&amp;gt; wrote in message &amp;lt;gc8gqk$49v$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;John Smith&quot; &amp;lt;cc200802@yahoo.com&amp;gt; wrote in message &amp;lt;gc7qv5$pv0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt;  I wanted to read in a file with the following format&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Date  number number &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; where date is a string such as &quot;4-Oct-08&quot; and numbers are floating point.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;  I want to be able to do some searches (using find) on the Date. How do I read in the file such that I can do the searches on the date ?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi John,&lt;br&gt;
&amp;gt; use textscan to read in the data, i.e. something like&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fname = 'c:\jsmith.txt';&lt;br&gt;
&amp;gt; fid = fopen(fname);&lt;br&gt;
&amp;gt; A = textscan(fid, '%s %f %f');&lt;br&gt;
&amp;gt; fclose(fid);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and if necessary apply one of the date functions (like datevec) to the first element of A (which stores the date strings in a cell array of strings). The respective doc pages will give you more insight into this.&lt;br&gt;
&amp;gt; I hope this gets you started.&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Andres</description>
    </item>
    <item>
      <pubDate>Sun, 05 Oct 2008 15:05:02 -0400</pubDate>
      <title>reading a data file to searches on Date</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237003#603784</link>
      <author>John Smith</author>
      <description>Thanks again for your help. I'm still strugling to achieve what I want. I'm not able to read the data and when I can see that I've read all the data into cell arrays.&lt;br&gt;
&lt;br&gt;
for example, i see&lt;br&gt;
&lt;br&gt;
when I print A, where A=textscan(fid, '%s %f %f');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{1202x1 cell}    [1202x1 double]    [1202x1 double]&lt;br&gt;
&lt;br&gt;
I now want to do something like&lt;br&gt;
IDX = find(A{1} == '05-Sep-08') &lt;br&gt;
it gives me error, &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
??? Undefined function or method 'eq' for input arguments of type 'cell'.&lt;br&gt;
&lt;br&gt;
so I tried &lt;br&gt;
IDX = find(datevec(A{1} == datevec(05-Sep-08'))&lt;br&gt;
&lt;br&gt;
??? Error using ==&amp;gt; eq&lt;br&gt;
Matrix dimensions must agree.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&lt;br&gt;
appreciate any help &lt;br&gt;
&lt;br&gt;
Thank you.&lt;br&gt;
&lt;br&gt;
John&lt;br&gt;
&lt;br&gt;
&quot;Andres &quot; &amp;lt;rantore@werb.deNoRs&amp;gt; wrote in message &amp;lt;gc8gqk$49v$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;John Smith&quot; &amp;lt;cc200802@yahoo.com&amp;gt; wrote in message &amp;lt;gc7qv5$pv0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt;  I wanted to read in a file with the following format&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Date  number number &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; where date is a string such as &quot;4-Oct-08&quot; and numbers are floating point.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;  I want to be able to do some searches (using find) on the Date. How do I read in the file such that I can do the searches on the date ?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi John,&lt;br&gt;
&amp;gt; use textscan to read in the data, i.e. something like&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fname = 'c:\jsmith.txt';&lt;br&gt;
&amp;gt; fid = fopen(fname);&lt;br&gt;
&amp;gt; A = textscan(fid, '%s %f %f');&lt;br&gt;
&amp;gt; fclose(fid);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and if necessary apply one of the date functions (like datevec) to the first element of A (which stores the date strings in a cell array of strings). The respective doc pages will give you more insight into this.&lt;br&gt;
&amp;gt; I hope this gets you started.&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Andres</description>
    </item>
    <item>
      <pubDate>Sun, 05 Oct 2008 16:30:17 -0400</pubDate>
      <title>reading a data file to searches on Date</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237003#603791</link>
      <author>Andres </author>
      <description>&quot;John Smith&quot; &amp;lt;cc200802@yahoo.com&amp;gt; wrote in message &amp;lt;gcal2u$aci$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; [..]&lt;br&gt;
&amp;gt; for example, i see&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; when I print A, where A=textscan(fid, '%s %f %f');&lt;br&gt;
&amp;gt;     {1202x1 cell}    [1202x1 double]    [1202x1 double]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I now want to do something like&lt;br&gt;
&amp;gt; IDX = find(A{1} == '05-Sep-08') &lt;br&gt;
&amp;gt; it gives me error, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Undefined function or method 'eq' for input arguments of type 'cell'.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; so I tried &lt;br&gt;
&amp;gt; IDX = find(datevec(A{1} == datevec(05-Sep-08'))&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; eq&lt;br&gt;
&amp;gt; Matrix dimensions must agree.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  &lt;br&gt;
&amp;gt; [..]&lt;br&gt;
&lt;br&gt;
Hi John,&lt;br&gt;
don't use &quot;==&quot; a) on strings or b) to compare whole rows, it's meant as a numeric element-by-element operation (type doc eq). Use a string function instead, like strmatch or its relatives - see the doc.&lt;br&gt;
Hth&lt;br&gt;
Andres</description>
    </item>
    <item>
      <pubDate>Mon, 06 Oct 2008 18:40:22 -0400</pubDate>
      <title>reading a data file to searches on Date</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/237003#603974</link>
      <author>John Smith</author>
      <description>Hi Andres,&lt;br&gt;
&amp;nbsp;Thank you very much.&lt;br&gt;
&lt;br&gt;
John&lt;br&gt;
&lt;br&gt;
&quot;Andres &quot; &amp;lt;rantore@werb.deNoRs&amp;gt; wrote in message &amp;lt;gcaq2p$7lv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;John Smith&quot; &amp;lt;cc200802@yahoo.com&amp;gt; wrote in message &amp;lt;gcal2u$aci$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; [..]&lt;br&gt;
&amp;gt; &amp;gt; for example, i see&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; when I print A, where A=textscan(fid, '%s %f %f');&lt;br&gt;
&amp;gt; &amp;gt;     {1202x1 cell}    [1202x1 double]    [1202x1 double]&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I now want to do something like&lt;br&gt;
&amp;gt; &amp;gt; IDX = find(A{1} == '05-Sep-08') &lt;br&gt;
&amp;gt; &amp;gt; it gives me error, &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ??? Undefined function or method 'eq' for input arguments of type 'cell'.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; so I tried &lt;br&gt;
&amp;gt; &amp;gt; IDX = find(datevec(A{1} == datevec(05-Sep-08'))&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ??? Error using ==&amp;gt; eq&lt;br&gt;
&amp;gt; &amp;gt; Matrix dimensions must agree.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;  &lt;br&gt;
&amp;gt; &amp;gt; [..]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi John,&lt;br&gt;
&amp;gt; don't use &quot;==&quot; a) on strings or b) to compare whole rows, it's meant as a numeric element-by-element operation (type doc eq). Use a string function instead, like strmatch or its relatives - see the doc.&lt;br&gt;
&amp;gt; Hth&lt;br&gt;
&amp;gt; Andres</description>
    </item>
  </channel>
</rss>

