<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245324</link>
    <title>MATLAB Central Newsreader - a simple control flow to find the index and replace</title>
    <description>Feed for thread: a simple control flow to find the index and replace</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, 25 Feb 2009 14:50:04 -0500</pubDate>
      <title>a simple control flow to find the index and replace</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245324#630731</link>
      <author>Kuo-Hsien </author>
      <description>Dear all,&lt;br&gt;
&lt;br&gt;
Here is my code to supplement missing data in the specific time based on the index.&lt;br&gt;
&lt;br&gt;
Can you advice me or provide me some hints how to write the part of control flow? I already try several way, but I need to pick up some clues.&lt;br&gt;
&lt;br&gt;
Thanks so much.&lt;br&gt;
Michael&lt;br&gt;
&lt;br&gt;
load ('data_A_2007');&lt;br&gt;
load ('data_B_2007');&lt;br&gt;
load ('data_C_2007');&lt;br&gt;
&lt;br&gt;
year = 2007;&lt;br&gt;
doy=yeardays(year);&lt;br&gt;
[L W] = size(year);&lt;br&gt;
&lt;br&gt;
if L &amp;lt; W;&lt;br&gt;
year = year';&lt;br&gt;
[L W] = size(year);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
ind = [1:1:L]';&lt;br&gt;
&lt;br&gt;
start_time = datenum(year(ind(1)), 1, 1) + step/1440;&lt;br&gt;
end_time = datenum(year(ind(L))+1, 1, 1);&lt;br&gt;
&lt;br&gt;
time_vector = [start_time : step/1440 : end_time]';&lt;br&gt;
base_vector = floor(time_vector(1,:));&lt;br&gt;
day_vector = time_vector - base_vector - doy;&lt;br&gt;
&lt;br&gt;
% summer time : doy &amp;gt;=91 and &amp;lt;=275; night time hour: 6 - 19&lt;br&gt;
% winter time : doy &amp;lt;90 and &amp;gt;275; night time hour: 7 - 18&lt;br&gt;
&lt;br&gt;
for day_vector(1:90*24*2 &amp; 275*24*2:end)&lt;br&gt;
night_index = find(floor(day_vector)&amp;lt; 7/24 | floor(day_vector)&amp;gt; 18/24);&lt;br&gt;
else&lt;br&gt;
night_index = find(floor(day_vector)&amp;lt; 6/24 | floor(day_vector)&amp;gt; 19/24);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
night_missingdata_index = find(data_A_2007(night_index) &amp; isnan(data_B_2007));&lt;br&gt;
data_A_2007(night_missingdata_index) = data_C_2007(night_missingdata_index);</description>
    </item>
    <item>
      <pubDate>Thu, 26 Feb 2009 13:27:02 -0500</pubDate>
      <title>Re: a simple control flow to find the index and replace</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245324#631025</link>
      <author>Kuo-Hsien </author>
      <description>Hi all, are there any suggestions and tips for this post? Thank so much. Michael</description>
    </item>
    <item>
      <pubDate>Thu, 26 Feb 2009 13:38:01 -0500</pubDate>
      <title>Re: a simple control flow to find the index and replace</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245324#631028</link>
      <author>us</author>
      <description>&quot;Kuo-Hsien&quot;&lt;br&gt;
&amp;gt; Hi all, are there any suggestions and tips for this post...&lt;br&gt;
&lt;br&gt;
you need to curtail your (tedious) idiosyncratic snippet (including files that are not accessible to CSSMers) to the very (bare bone) problem - in easily copy/pasteable code - you want this NG to look at...&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
    <item>
      <pubDate>Fri, 27 Feb 2009 07:39:01 -0500</pubDate>
      <title>Re: a simple control flow to find the index and replace</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245324#631255</link>
      <author>Kuo-Hsien </author>
      <description>Thanks for your helps. I should make it more clearer and readable. &lt;br&gt;
&lt;br&gt;
Here is my two problems: &lt;br&gt;
(1) how to do some judgement based on a specific range of index? &lt;br&gt;
(2) how to approach my purpose by utilizing if ... end or while ... end? &lt;br&gt;
&lt;br&gt;
For example, I create a series of index&amp;lt;8760x1 double&amp;gt;, I like to sort out the index based on the conditions: (a) location from 1 to 1000, 8000 to the end and the rest; (b) the decimal value from 0 to 0.3, 0.7 to 1 and the rest. &lt;br&gt;
&lt;br&gt;
index = repmat((0:1/24:0.9584)',[365 1]);&lt;br&gt;
value = rand(1,8760)';&lt;br&gt;
&lt;br&gt;
if index(1:1000 &amp; 8000:end)&lt;br&gt;
index_tail=find(floor(index)&amp;lt;0.3 | floor(index)&amp;gt;0.7)&lt;br&gt;
else&lt;br&gt;
index_mid=find(floor(index)&amp;gt;=0.3 | floor(index)&amp;lt;=0.7)&lt;br&gt;
if index(1001:7999)&lt;br&gt;
index_tail=find(floor(index)&amp;lt;0.3 | floor(index)&amp;gt;0.7)&lt;br&gt;
else&lt;br&gt;
index_mid=find(floor(index)&amp;gt;=0.3 | floor(index)&amp;lt;=0.7)&lt;br&gt;
end&lt;br&gt;
index_final = find((index_tail) &amp; value&amp;gt;0.8);&lt;br&gt;
&lt;br&gt;
Please advice me how to correct my code. If I did not make my question clear or misunderstand the logics, please feel free to let me know. Thanks for your advices.&lt;br&gt;
&lt;br&gt;
Michael</description>
    </item>
    <item>
      <pubDate>Fri, 27 Feb 2009 07:41:03 -0500</pubDate>
      <title>Re: a simple control flow to find the index and replace</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245324#631256</link>
      <author>Kuo-Hsien </author>
      <description>Thanks for your helps. I should make it more clearer and readable. &lt;br&gt;
&lt;br&gt;
Here is my two problems: &lt;br&gt;
(1) how to do some judgement based on a specific range of index? &lt;br&gt;
(2) how to approach my purpose by utilizing if ... end or while ... end? &lt;br&gt;
&lt;br&gt;
For example, I create a series of index&amp;lt;8760x1 double&amp;gt;, I like to sort out the index based on the conditions: (a) location from 1 to 1000, 8000 to the end and the rest; (b) the decimal value from 0 to 0.3, 0.7 to 1 and the rest. &lt;br&gt;
&lt;br&gt;
index = repmat((0:1/24:0.9584)',[365 1]);&lt;br&gt;
value = rand(1,8760)';&lt;br&gt;
&lt;br&gt;
if index(1:1000 &amp; 8000:end)&lt;br&gt;
index_tail=find(floor(index)&amp;lt;0.3 | floor(index)&amp;gt;0.7)&lt;br&gt;
else&lt;br&gt;
index_mid=find(floor(index)&amp;gt;=0.3 | floor(index)&amp;lt;=0.7)&lt;br&gt;
if index(1001:7999)&lt;br&gt;
index_tail=find(floor(index)&amp;lt;0.3 | floor(index)&amp;gt;0.7)&lt;br&gt;
else&lt;br&gt;
index_mid=find(floor(index)&amp;gt;=0.3 | floor(index)&amp;lt;=0.7)&lt;br&gt;
end&lt;br&gt;
index_final = find((index_tail) &amp; value&amp;gt;0.8);&lt;br&gt;
&lt;br&gt;
Please advice me how to correct my code. If I did not make my question clear or misunderstand the logics, please feel free to let me know. Thanks for your advices.&lt;br&gt;
&lt;br&gt;
Michael</description>
    </item>
  </channel>
</rss>

