Professional Documents
Culture Documents
Concepts of Geodesy and Geodetic Methods Exercise 4
Concepts of Geodesy and Geodetic Methods Exercise 4
1.0 Introduction
In this exercise we were asked to fit a polynomial of degree n (where n is an
appropriate degree) to the given time series. The time series gives the air
temperature for 30days of November 2017 for a mountain station in south
Germany.
The given instructions in the exercise were followed in order to complete the
task.
2.0 Task 1
In the first task we were required to use the Matlab file “ Data4Polyfit.mat and
load it in MATLAB. We considered the data file with two variables “t” and
“Y”. The data collected was for 30 days with a sampling rate of 30 minutes .
In the first task after following the instructions a polynomial of degree 4 with
estimated corresponding coefficients resulted in the figure below.
3.0 Task 2
Degree RMSE
2 3.31192194278123e-15 + 0.00000000000000i
3 0.00000000000000 + 1.39978092124609e-21i
4 1.09941198885324e-29 + 0.00000000000000i
5 5.04975390864909e-35 + 0.00000000000000i
6 9.01067731909221e-41 + 0.00000000000000i
5.0 Task 4
6.0 Task 5
The noise level in the data could be estimated by looking at the frequency and
shape of the oscillation. In this case it is coloured noise because the oscillation
is not flat.
Refernces
Source code:
clc;
clear;
close all;
%%Task 1
load Data4Polyfit.mat % to load the data
t_1 = t/30;
y_1 = Y;
figure(1);
plot(t_1,y_1);
grid on
title('Plot of Air temperature in 30days');
xlabel('time(minutes)'); %Defining t axis
ylabel('Temperature(degrees celcius)'); %Defining y axis
hold on
A = [ones(size(t)) t t.^2 t.^3 t.^4]; %design matrix
y_c = A*x;
plot(t_1,y_c,'y'); %image with line with best line of fit from degree (n)=4
%%Task 2
a=rand(1439,1); % generate random data
[TRS]= intersect(a,randsample(a,1150)); % gives training set with 80%
random samples from a you can set what size your trainign set needs to be
TS=a(~ismember(a,TRS)); % gives test set
%n=2
A1 = [ones(size(TRS)) TRS TRS.^2 ]; %design matrix
RMS1=sqrt(sum([TRS-y_c1]).^2/289);
%n=3
A2 = [ones(size(TRS)) TRS TRS.^2 TRS.^3 ]; %design matrix
RMS2=sqrt(sum([TRS-y_c2]).^3/289);
%n=4
A3 = [ones(size(TRS)) TRS TRS.^2 TRS.^3 TRS.^4 ]; %design matrix
%n=5
A4 = [ones(size(TRS)) TRS TRS.^2 TRS.^3 TRS.^4 TRS.^5 ]; %design matrix
RMS4=sqrt(sum([TRS-y_c4]).^5/289);
%n=6
A5 = [ones(size(TRS)) TRS TRS.^2 TRS.^3 TRS.^4 TRS.^5 TRS.^6 ]; %design
matrix
RMS5=sqrt(sum([TRS-y_c5]).^6/289);