Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: a simple control flow to find the index and replace
Date: Wed, 25 Feb 2009 14:50:04 +0000 (UTC)
Organization: CSU
Lines: 42
Message-ID: <go3lqs$md3$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1235573404 22947 172.30.248.37 (25 Feb 2009 14:50:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 25 Feb 2009 14:50:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 951788
Xref: news.mathworks.com comp.soft-sys.matlab:520716


Dear all,

Here is my code to supplement missing data in the specific time based on the index.

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.

Thanks so much.
Michael

load ('data_A_2007');
load ('data_B_2007');
load ('data_C_2007');

year = 2007;
doy=yeardays(year);
[L W] = size(year);

if L < W;
year = year';
[L W] = size(year);
end

ind = [1:1:L]';

start_time = datenum(year(ind(1)), 1, 1) + step/1440;
end_time = datenum(year(ind(L))+1, 1, 1);

time_vector = [start_time : step/1440 : end_time]';
base_vector = floor(time_vector(1,:));
day_vector = time_vector - base_vector - doy;

% summer time : doy >=91 and <=275; night time hour: 6 - 19
% winter time : doy <90 and >275; night time hour: 7 - 18

for day_vector(1:90*24*2 & 275*24*2:end)
night_index = find(floor(day_vector)< 7/24 | floor(day_vector)> 18/24);
else
night_index = find(floor(day_vector)< 6/24 | floor(day_vector)> 19/24);
end

night_missingdata_index = find(data_A_2007(night_index) & isnan(data_B_2007));
data_A_2007(night_missingdata_index) = data_C_2007(night_missingdata_index);