I used version is
----------------------------------------------------------------------------------------------------
MATLAB Version: 8.0.0.783 (R2012b)
MATLAB License Number: ••••••
Operating System: Linux 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64
Java Version: Java 1.7.0_55-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 8.0 (R2012b)
Simulink Version 8.0 (R2012b)
Curve Fitting Toolbox Version 3.3 (R2012b)
Database Toolbox Version 4.0 (R2012b)
Global Optimization Toolbox Version 3.2.2 (R2012b)
Image Processing Toolbox Version 8.1 (R2012b)
Optimization Toolbox Version 6.2.1 (R2012b)
Parallel Computing Toolbox Version 6.1 (R2012b)
Partial Differential Equation Toolbox Version 1.1 (R2012b)
Signal Processing Toolbox Version 6.18 (R2012b)
Statistics Toolbox Version 8.1 (R2012b)
I draw plot I used datenum and datetick
I attach my plot. this plot x tick is no match.
for example Tidal Wavelet Power Spectrum plot(4,1,1) "12/19 00" is originally "12/20 00".
what's the problem?
----------------------my program--------------------------------------------------------
%saveext='.png'
filepath='./34_tide_01.dat'
[path,name,ext] =fileparts(filepath)
%x=load('yg_2005_12.txt');
dat=load(filepath);
dox=19 % start julian day
doy=dox+3 %end day
date_v=datenum(dat(:,1), dat(:,2), dat(:,3), dat(:,4), dat(:,5), dat(:,6))
%datetick('x','mm/dd hh')
x=dat(:,11);
num=size(x);
for i = 1:num(1)
if x(i) < 0
x(i)= NaN;
end
end
%Tide interpolation
for i = 1:num(1)
if isnan(x(i)) ==1
if i-5 <= 0
% x(i)=nanmean(x(i:i+5));
angle=nanmean(x(i:i+5));
if isnan(x(i+1)) ==0
inter=x(i+1)-angle*(i+1)
elseif isnan(x(i+2)) ==0
inter=x(i+2)-angle*(i+2)
elseif isnan(x(i+3)) ==0
inter=x(i+3)-angle*(i+3)
elseif isnan(x(i+4)) ==0
inter=x(i+4)-angle*(i+4)
elseif isnan(x(i+5)) ==0
inter=x(i+5)-angle*(i+5)
end
elseif i+5 >= num(1)
x(i)=nanmean(x(i-5:i));
else
x(i)=nanmean(x(i-5:i+5));
end
end
end
%date(:,11)=interp1(date(:,11),1,)
%x=dat(:,11);
%------------------------------------------high pass filter
hour=1
Fs=1.0/60.0; %fampling frequency
Fs=1
n=9; %order
%Wn=1/(3600*12+60*25) %cut off frequency 10Hz
Wn=1/(hour*3600);
Wn=1/60
Fn=Fs/2; %Nyquist frequency
ftype='high' %bandpass or low or high
[b,a]=butter(n,Wn/Fn,ftype);
y=filter(b,a,x);
%tide return NaN
for i = 1:num(1)
if isnan(x(i)) ==1
if i-5 <= 0
y(i:i+5)=0;
x(i:i+5)=NaN
elseif i+5 >= num(1)
y(i-5:i)=0;
x(i-5:i)=NaN
else
y(i-5:i+5)=0;
x(i-5:i+5)=NaN
end
end
end
x=x(dox*1440:doy*1440)
y=y(dox*1440:doy*1440)
date_v=date_v(dox*1440:doy*1440)
num=size(x);
%-----------------------------------wavelet transform
%sst=y(dox*1440:doy*1440)
sst=y;
variance = std(sst)^2;
sst = (sst - mean(sst))/sqrt(variance) ;
n = length(sst);
%dt = 0.25 ;
dt = 1
time = date_v ; % construct time array
%xlim = [1,1440]; % plotting range
pad = 1; % pad the time series with zeroes (recommended)
%dj = 0.25; % this will do 4 sub-octaves per octave
dj = 0.25
s0 = 2*dt; % this says start at a scale of 6 months
j1 = 5/dj; % this says do 7 powers-of-two with dj sub-octaves each
lag1 = 0.72; % lag-1 autocorrelation for red noise background
mother = 'Morlet';
% Wavelet transform:
[wave,period,scale,coi] = wavelet(sst,dt,pad,dj,s0,j1,mother);
power = (abs(wave)).^2 ; % compute wavelet power spectrum
% Significance levels: (variance=1 for the normalized SST)
[signif,fft_theor] = wave_signif(1.0,dt,scale,0,lag1,-1,-1,mother);
sig95 = (signif')*(ones(1,n)); % expand signif --> (J+1)x(N) array
sig95 = power ./ sig95; % where ratio > 1, power is significant
% Global wavelet spectrum & significance levels:
global_ws = variance*(sum(power')/n); % time-average over all times
dof = n - scale; % the -scale corrects for padding at edges
global_signif = wave_signif(variance,dt,scale,1,lag1,-1,dof,mother);
% Scale-average between El Nino periods of 2--8 years
avg = find((scale >= 2) & (scale < 8));
Cdelta = 0.776; % this is for the MORLET wavelet
scale_avg = (scale')*(ones(1,n)); % expand scale --> (J+1)x(N) array
scale_avg = power ./ scale_avg; % [Eqn(24)]
scale_avg = variance*dj*dt/Cdelta*sum(scale_avg(avg,:)); % [Eqn(24)]
scaleavg_signif = wave_signif(variance,dt,scale,2,lag1,-1,[2,7.9],mother);
whos
levels = [4,8,16,32,64,128,256] ;
Yticks = 2.^(fix(log2(min(period))):fix(log2(max(period))));
%contour(time,log2(period),log2(power),log2(levels)); %*** or use 'contourfill'
%contour(time,log2(period),log2(power),log2(levels))
%subplot('position',[0.1 0.75 0.65 0.2])
subplot(4,1,1)
%imagesc(time,log2(period),log2(power)); %*** uncomment for 'image' plot
imagesc(time,log2(period),log2(power),'CDataMapping','scaled')
colormap(jet)
%contour(time,log2(period),log2(power),'CDataMapping','scaled')
%contourf(time,log2(period),log2(power),'CDataMapping','scaled')
%caxis([0,])
%set(gca,'XMinorTick','on','XMinorGrid','on')
xlabel('Time(KST)')
datetick('x','mm/dd hh')
set(gca,'XLim',[time(1),time(num(1))])
set(gca,'XTick',[time(1):0.125:time(num(1))])
grid on
ylabel('Period (min)')
title('Tidal Wavelet Power Spectrum')
set(gca,'YLim',log2([min(period),max(period)]), ...
'YDir','reverse', ...
'YTick',log2(Yticks(:)), ...
'YTickLabel',Yticks)
% 95% significance contour, levels at -99 (fake) and 1 (95% signidatf)
hold on
contour(time,log2(period),sig95,[-99,1],'k');
hold on
% cone-of-influence, anything "below" is dubious
plot(time,log2(coi),'k')
hold off
%num=size(time)
for i = 1:num(1)
powerserise(i) = max(power(:,i));
end
subplot(4,1,2)
plot(date_v,powerserise)
datetick('x','mm/dd hh')
set(gca,'XLim',[date_v(1),date_v(num(1))])
subplot(4,1,3)
%plot(y(dox*1440:doy*1440))
plot(date_v,y)
datetick('x','mm/dd hh')
set(gca,'XLim',[date_v(1),date_v(num(1))])
subplot(4,1,4)
%plot(x(dox*1440:doy*1440))
plot(date_v,x)
datetick('x','mm/dd hh')
set(gca,'XLim',[date_v(1),date_v(num(1))])

回答 (0 件)

カテゴリ

製品

タグ

質問済み:

2015 年 7 月 16 日

編集済み:

2015 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by