<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265188</link>
    <title>MATLAB Central Newsreader - error on running eval and save</title>
    <description>Feed for thread: error on running eval and save</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>Fri, 06 Nov 2009 16:54:02 -0500</pubDate>
      <title>error on running eval and save</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265188#692722</link>
      <author>Kuo-Hsien </author>
      <description>Dear all,&lt;br&gt;
&lt;br&gt;
I stuck by my code for couple days. I come here to ask any guidance and suggestions. Please kindly point the problems and solutions out. Thanks. My purpose is to create new files contain NaNs &amp;lt;48x1 double&amp;gt; and the file names are named by date. The desired file names will be picking up from a &amp;lt;366x1 cell&amp;gt; tmp_filenames by ismember.  &lt;br&gt;
&lt;br&gt;
The error message is:&lt;br&gt;
??? Error using ==&amp;gt; eval&lt;br&gt;
Undefined function or method 'save20080101fillin' for input arguments of type 'char'.&lt;br&gt;
&lt;br&gt;
What should I do? &lt;br&gt;
&lt;br&gt;
----------------------------------&lt;br&gt;
[tf, index] = ismember(tmp_filenames,filename_4_compare);&lt;br&gt;
for n = 1:length(find(index == 0))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fillin_filename = [tmp_filenames(n)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fillin_filename = cell2mat(fillin_filename)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fillin = ones(48,1) * NaN&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;eval(['save' ,fillin_filename ,'fillin -ascii'])&lt;br&gt;
end&lt;br&gt;
----------------------------------&lt;br&gt;
index : &amp;lt;366x1 double&amp;gt;&lt;br&gt;
tmp_filenames : &amp;lt;366x1 cell&amp;gt;&lt;br&gt;
filename_4_compare : &amp;lt;10x1 cell&amp;gt;</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 17:23:04 -0500</pubDate>
      <title>Re: error on running eval and save</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265188#692728</link>
      <author>someone </author>
      <description>&quot;Kuo-Hsien&quot; &amp;lt;mchangks@hotmail.com&amp;gt; wrote in message &amp;lt;hd1kba$dvr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Dear all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I stuck by my code for couple days. I come here to ask any guidance and suggestions. Please kindly point the problems and solutions out. Thanks. My purpose is to create new files contain NaNs &amp;lt;48x1 double&amp;gt; and the file names are named by date. The desired file names will be picking up from a &amp;lt;366x1 cell&amp;gt; tmp_filenames by ismember.  &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The error message is:&lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; eval&lt;br&gt;
&amp;gt; Undefined function or method 'save20080101fillin' for input arguments of type 'char'.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What should I do? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ----------------------------------&lt;br&gt;
&amp;gt; [tf, index] = ismember(tmp_filenames,filename_4_compare);&lt;br&gt;
&amp;gt; for n = 1:length(find(index == 0))&lt;br&gt;
&amp;gt;     fillin_filename = [tmp_filenames(n)]&lt;br&gt;
&amp;gt;     fillin_filename = cell2mat(fillin_filename)&lt;br&gt;
&amp;gt;     fillin = ones(48,1) * NaN&lt;br&gt;
&amp;gt;     eval(['save' ,fillin_filename ,'fillin -ascii'])&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; ----------------------------------&lt;br&gt;
&amp;gt; index : &amp;lt;366x1 double&amp;gt;&lt;br&gt;
&amp;gt; tmp_filenames : &amp;lt;366x1 cell&amp;gt;&lt;br&gt;
&amp;gt; filename_4_compare : &amp;lt;10x1 cell&amp;gt;&lt;br&gt;
&lt;br&gt;
% I think you need to add some spaces after save.&lt;br&gt;
% replace:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;eval(['save' ,fillin_filename ,'fillin -ascii'])&lt;br&gt;
% with&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;eval(['save ' ,fillin_filename ,' fillin -ascii'])</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 17:26:10 -0500</pubDate>
      <title>Re: error on running eval and save</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265188#692729</link>
      <author>someone </author>
      <description>&quot;Kuo-Hsien&quot; &amp;lt;mchangks@hotmail.com&amp;gt; wrote in message &amp;lt;hd1kba$dvr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Dear all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I stuck by my code for couple days. I come here to ask any guidance and suggestions. Please kindly point the problems and solutions out. Thanks. My purpose is to create new files contain NaNs &amp;lt;48x1 double&amp;gt; and the file names are named by date. The desired file names will be picking up from a &amp;lt;366x1 cell&amp;gt; tmp_filenames by ismember.  &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The error message is:&lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; eval&lt;br&gt;
&amp;gt; Undefined function or method 'save20080101fillin' for input arguments of type 'char'.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What should I do? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ----------------------------------&lt;br&gt;
&amp;gt; [tf, index] = ismember(tmp_filenames,filename_4_compare);&lt;br&gt;
&amp;gt; for n = 1:length(find(index == 0))&lt;br&gt;
&amp;gt;     fillin_filename = [tmp_filenames(n)]&lt;br&gt;
&amp;gt;     fillin_filename = cell2mat(fillin_filename)&lt;br&gt;
&amp;gt;     fillin = ones(48,1) * NaN&lt;br&gt;
&amp;gt;     eval(['save' ,fillin_filename ,'fillin -ascii'])&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; ----------------------------------&lt;br&gt;
&amp;gt; index : &amp;lt;366x1 double&amp;gt;&lt;br&gt;
&amp;gt; tmp_filenames : &amp;lt;366x1 cell&amp;gt;&lt;br&gt;
&amp;gt; filename_4_compare : &amp;lt;10x1 cell&amp;gt;&lt;br&gt;
&lt;br&gt;
% I think you need to add some spaces after save.&lt;br&gt;
% replace:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;eval(['save' ,fillin_filename ,'fillin -ascii'])&lt;br&gt;
% with&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;eval(['save ' ,fillin_filename ,' fillin -ascii'])</description>
    </item>
    <item>
      <pubDate>Fri, 06 Nov 2009 17:53:14 -0500</pubDate>
      <title>Re: error on running eval and save</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265188#692732</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Kuo-Hsien&quot; &amp;lt;mchangks@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:hd1kba$dvr$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Dear all,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I stuck by my code for couple days. I come here to ask any guidance and &lt;br&gt;
&amp;gt; suggestions. Please kindly point the problems and solutions out. Thanks. &lt;br&gt;
&amp;gt; My purpose is to create new files contain NaNs &amp;lt;48x1 double&amp;gt; and the file &lt;br&gt;
&amp;gt; names are named by date. The desired file names will be picking up from a &lt;br&gt;
&amp;gt; &amp;lt;366x1 cell&amp;gt; tmp_filenames by ismember.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The error message is:&lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; eval&lt;br&gt;
&amp;gt; Undefined function or method 'save20080101fillin' for input arguments of &lt;br&gt;
&amp;gt; type 'char'.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; What should I do?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ----------------------------------&lt;br&gt;
&amp;gt; [tf, index] = ismember(tmp_filenames,filename_4_compare);&lt;br&gt;
&amp;gt; for n = 1:length(find(index == 0))&lt;br&gt;
&amp;gt;    fillin_filename = [tmp_filenames(n)]&lt;br&gt;
&amp;gt;    fillin_filename = cell2mat(fillin_filename)&lt;br&gt;
&lt;br&gt;
If tmp_filenames is a cell array where each cell contains a file name, you &lt;br&gt;
can replace the previous two lines with:&lt;br&gt;
&lt;br&gt;
fillin_filename = tmp_filenames{n};&lt;br&gt;
&lt;br&gt;
&amp;gt;    fillin = ones(48,1) * NaN&lt;br&gt;
&amp;gt;    eval(['save' ,fillin_filename ,'fillin -ascii'])&lt;br&gt;
&lt;br&gt;
Remove the EVAL call and use the functional form of SAVE:&lt;br&gt;
&lt;br&gt;
save(fillin_filename, 'fillin', '-ascii');&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com&lt;br&gt;
comp.soft-sys.matlab (CSSM) FAQ: &lt;a href=&quot;http://matlabwiki.mathworks.com/MATLAB_FAQ&quot;&gt;http://matlabwiki.mathworks.com/MATLAB_FAQ&lt;/a&gt; </description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 03:59:03 -0500</pubDate>
      <title>Re: error on running eval and save</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265188#692956</link>
      <author>Kuo-Hsien </author>
      <description>Hi Steve, it works!! Thanks. One more question: if I like to save the files to a desired path, such as: /Users/cks/Documents/Matlab/&lt;br&gt;
&lt;br&gt;
And, I also set a path for the desired path as: pathway = '/Users/cks/Documents/Matlab/'&lt;br&gt;
&lt;br&gt;
How to modify the following code correctly?&lt;br&gt;
eval(['save pathway/fillin_filename', 'fillin -ascii'])&lt;br&gt;
&lt;br&gt;
Thanks Steve.</description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 23:17:59 -0500</pubDate>
      <title>Re: error on running eval and save</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265188#693091</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Kuo-Hsien&quot; &amp;lt;mchangks@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:hd5fm7$5sc$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi Steve, it works!! Thanks. One more question: if I like to save the &lt;br&gt;
&amp;gt; files to a desired path, such as: /Users/cks/Documents/Matlab/&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; And, I also set a path for the desired path as: pathway = &lt;br&gt;
&amp;gt; '/Users/cks/Documents/Matlab/'&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; How to modify the following code correctly?&lt;br&gt;
&amp;gt; eval(['save pathway/fillin_filename', 'fillin -ascii'])&lt;br&gt;
&lt;br&gt;
DON'T USE EVAL IN THIS CASE.&lt;br&gt;
&lt;br&gt;
Separate the construction of the file name (which will use some of the &lt;br&gt;
string processing functions) from the SAVE call.&lt;br&gt;
&lt;br&gt;
realfilename = [pathway filename];&lt;br&gt;
% or use FULLFILE&lt;br&gt;
&lt;br&gt;
save(realfilename, 'filln', '-ascii')&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com&lt;br&gt;
comp.soft-sys.matlab (CSSM) FAQ: &lt;a href=&quot;http://matlabwiki.mathworks.com/MATLAB_FAQ&quot;&gt;http://matlabwiki.mathworks.com/MATLAB_FAQ&lt;/a&gt; </description>
    </item>
  </channel>
</rss>

