I have a problem with drawing on the timeline

1 vue (au cours des 30 derniers jours)
peter huang
peter huang le 16 Fév 2022
Modifié(e) : peter huang le 16 Fév 2022
clear all ; clc ; clf ;
set(gcf,'color','w')
%% load data
filehtm = dir('moving_windown_test.xlsx') ;
for ii = 1 : length(filehtm);
filehtm(ii).name
[num,str,xlsdata] = xlsread(filehtm(ii).name) ; %num數值 str字串
end
%% set time
time = num(:,1) ;
tide_detrend = num(:,2) ./ 1000 ;
tide = tide_detrend ;
tide_raw = tide_detrend;
%% set time
YYYY = fix(time/1000000) ;
MM = mod(fix(time/10000),100) ;
DD = mod(fix(time/100),100) ;
HH = mod(time,100) ;
tt = datenum(YYYY,MM,DD,HH,0,0) ;
%% loop movingwindown
for k = 1:1:5
yyyy(k) = 1960 +k;
t1 = datenum( yyyy(k),1,1) : 1/24 : datenum( yyyy(k)+1,1,1);
t1(end)=[];
year = YYYY;
index = find(year == yyyy(k));
t = tt(index); % movingwindown 時間
Q1(k) = prctile(tide(index), 25) ;
Q3(k) = prctile(tide(index), 75);
IQR(k) = Q3(k) - Q1(k) ;
upper(k) = Q3(k) + 1.5*IQR(k)
lower(k) = Q1(k) - 1.5*IQR(k)
tide_outline = tide(index);
raw_tide = tide(index);
tide_outline(tide_outline > upper(k) | tide_outline < lower(k)) = nan;
for j = 1 : length(t1);
if (isempty(find(t==t1(j))));
r_tide(j) = nan ;
else
r_tide(j) = tide_outline(find(t==t1(j))) ;
end
end
for j = 1 : length(t1);
if (isempty(find(t==t1(j))));
r_tide(j) = nan ;
else
r_tide_1(j) = raw_tide(find(t==t1(j))) ;
end
end
for i = 1 : length(t1) ;
field_day(i) = (yyyy(k)+(i - 1) * 60 * 60 / 86400/365) ;
end
plot([yyyy(k),yyyy(k)+1],[upper(k),upper(k)],'-r');hold on
plot([yyyy(k),yyyy(k)+1],[lower(k),lower(k)],'-b');
% plot(field_day,r_tide, 'b' ) ; hold on %remove outliner
plot(field_day,r_tide_1 );hold on % rawdata
end

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by