<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173125</link>
    <title>MATLAB Central Newsreader - Question on IF statements, I think...</title>
    <description>Feed for thread: Question on IF statements, I think...</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>Wed, 23 Jul 2008 18:50:04 -0400</pubDate>
      <title>Question on IF statements, I think...</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173125#444959</link>
      <author>jeremy </author>
      <description>I've got the following code which is doing almost just what&lt;br&gt;
I want it to do...  &lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;load HC_actual;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;New_measurement = input('Enter new x/y data pair: ');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;HC_Chart_actual(end+1,:) = New_measurement;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;save HC_actual&lt;br&gt;
&lt;br&gt;
Now for the question...  How do I put the above code in my&lt;br&gt;
M-file so that I can, from the command prompt, opt to enter&lt;br&gt;
new data or just go on with the M-file without adding new&lt;br&gt;
data to the HC_actual array?  &lt;br&gt;
&lt;br&gt;
Basically, I want a Command Window prompt that asks &quot;Do you&lt;br&gt;
want to enter new data?&quot; and depending on whether I type in&lt;br&gt;
'y' or 'n', the program either does the above code or skips&lt;br&gt;
the code and continues the routine.  &lt;br&gt;
&lt;br&gt;
Any suggestions?  &lt;br&gt;
&lt;br&gt;
Thanks!  Jeremy</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 19:01:05 -0400</pubDate>
      <title>Re: Question on IF statements, I think...</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173125#444963</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g67ugs$6bl$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
jeremy  &amp;lt;rower15@excite.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;I've got the following code which is doing almost just what&lt;br&gt;
&amp;gt;I want it to do...  &lt;br&gt;
&lt;br&gt;
&amp;gt;   load HC_actual;&lt;br&gt;
&lt;br&gt;
I would suggest that you get used to using the function form of load:&lt;br&gt;
Matlab can do much better optimization if it doesn't have to deal with&lt;br&gt;
variables in the workspace suddenly popping into existance.&lt;br&gt;
You cannot (easily) use the command version of 'load' if you&lt;br&gt;
are using nested functions for example.&lt;br&gt;
&lt;br&gt;
&amp;gt;   New_measurement = input('Enter new x/y data pair: ');&lt;br&gt;
&amp;gt;   HC_Chart_actual(end+1,:) = New_measurement;&lt;br&gt;
&amp;gt;   save HC_actual&lt;br&gt;
&lt;br&gt;
&amp;gt;Now for the question...  How do I put the above code in my&lt;br&gt;
&amp;gt;M-file so that I can, from the command prompt, opt to enter&lt;br&gt;
&amp;gt;new data or just go on with the M-file without adding new&lt;br&gt;
&amp;gt;data to the HC_actual array?  &lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;Basically, I want a Command Window prompt that asks &quot;Do you&lt;br&gt;
&amp;gt;want to enter new data?&quot; and depending on whether I type in&lt;br&gt;
&amp;gt;'y' or 'n', the program either does the above code or skips&lt;br&gt;
&amp;gt;the code and continues the routine.  &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
HC_struct = load('HC_actual.mat');&lt;br&gt;
if ~isfield(HC_struct, 'HC_Chart_actual')&lt;br&gt;
&amp;nbsp;&amp;nbsp;error('Corrupt HC_actual file!');&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
addsomething = input('Do you want to enter new data? Y/[N]', 's');&lt;br&gt;
if ~isempty(addsomething) &amp;&amp; strcmpi(strtrim(addsomething),'y')&lt;br&gt;
&amp;nbsp;&amp;nbsp;New_measurement = input('Enter new x/y data pair: ');&lt;br&gt;
&amp;nbsp;&amp;nbsp;HC_struct.HC_Chart_actual(end+1,:) = New_measurement;&lt;br&gt;
&amp;nbsp;&amp;nbsp;save('HC_actual.mat', 'HC_struct', '-struct');&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
This code assumes that, either way, you will want HC_Chart_actual&lt;br&gt;
in your workspace after the section of code. If you don't need&lt;br&gt;
HC_Chart_actual unless the user wants to update it, then&lt;br&gt;
you can move the load() call and associated sanity check&lt;br&gt;
inside of the if statement.&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;Ignorance has been our king... he sits unchallenged on the throne of&lt;br&gt;
&amp;nbsp;&amp;nbsp;Man. His dynasty is age-old. His right to rule is now considered&lt;br&gt;
&amp;nbsp;&amp;nbsp;legitimate. Past sages have affirmed it. They did nothing to unseat&lt;br&gt;
&amp;nbsp;&amp;nbsp;him.&quot;                                       -- Walter M Miller, Jr</description>
    </item>
  </channel>
</rss>

