Cod FReg

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

%%% Variable Cleanup clear all clc %%% Data reading TEMP = dlmread('temp.dat',' ',3,0); RAIN = dlmread('rain.

dat',' ',3,0); AT = zeros(365,2); AR = zeros(365,2); AT(:,1) = (1:365); AT(:,2) = (1); AR(:,1) = (1:365); AR(:,2) = (1); %%% Calculation of covariance matrix of TEMP COVT = (((inv(AT'*AT))*AT')*cov(TEMP(:,2))*((inv(AT'*AT))*AT')'); %%% Calculation of covariance matrix of RAIN COVR = (((inv(AR'*AR))*AR')*cov(TEMP(:,2))*((inv(AR'*AR))*AR')'); %%% Calculation of sdev, var and corrcoef of datasets sdevT = std(TEMP(:,2)); sdevR = std(RAIN(:,2)); varT = var(TEMP(:,2)); varR = var(RAIN(:,2)); COVRT = cov(TEMP(:,2),RAIN(:,2)); CCTR = corrcoef(TEMP(:,2),RAIN(:,2)); %%% Plots and linear fitting %%% Plots figure plot (TEMP(:,1),TEMP(:,2)); figure plot (RAIN(:,1),RAIN(:,2)); %%% Linear fitting xT = TEMP(:,1); yT = TEMP(:,2);

pT = polyfit(xT,yT,1); ypT = polyval(pT,xT); figure plot (TEMP(:,1),TEMP(:,2)); hold on plot (xT,ypT) xR = RAIN(:,1); yR = RAIN(:,2); pR = polyfit(xR,yR,1); ypR = polyval(pR,xR); figure plot (RAIN(:,1),RAIN(:,2)); hold on plot (xR,ypR) %%% Trendline substraction and Fourier Transform %Detrending allows to notice fluctuations around the mean dtT = detrend(TEMP(:,2)); dtR = detrend(RAIN(:,2)); fftT = fftshift(fft(dtT)); fftR = fftshift(fft(dtR)); %%% Sampling frequency and frequency vector determination Ts = 24*60*60; Fs = 1/Ts; Fvect = (-Fs/2:Fs/364:Fs/2); %%% Spectrum plots %Frequency figure plot(Fvect,abs(fftT)) figure plot(Fvect,abs(fftR)) %Period for k=1:365 Tvect(1,k) = 1/Fvect(1,k) end

figure plot(Tvect,abs(fftT)) figure plot(Tvect,abs(fftR))

You might also like