how to add a moving average filter
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a data that is orgnized in the following way:
In the first column I have years from 1950 - 2011. In the 2nd column I have months ranging from 1 - 12. In the 3rd column i have and index which is a assocated with a number.
Example of data:
1950 1 0.73
1950 2 0.44
and so forth.
I have the following code to plot ithe data annually.
clear all
clear all
tfile2='cpc_monthly_nao.ascii';
fid2=fopen(tfile2,'r');
[year_m,month,index_month]=textread(tfile2,'%d %d %f');
ind=1;
m=size(index_month);
for ii=1:12:m
year(ind)=year_m(ii);
% DJFM
if ii > 1
index(ind)=(index_month(ii-1)+index_month(ii)+index_month(ii+1)+index_month(ii+2)+index_month(ii+3)+index_month(ii+4)+index_month(ii+5)+index_month(ii+6)+index_month(ii+7)+index_month(ii+8)+index_month(ii+9)+index_month(ii+10)+index_month(ii+11))/12.0;
ind=ind+1;
end
end
hold on
bar(year,index,'k')
plot(year,0.0,'b')
[y,i]=sort(index);
year(i)
[y2,i2]=sort(abs(index));
year(i2)
The above code plots the data annually. I now want to plot the data annually with a 3 month moving average filter. How do I do that?
0 Kommentare
Antworten (1)
Siehe auch
Kategorien
Mehr zu Analog Filters finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!