Vous êtes sur la page 1sur 6

ALBERT-LUDWIGS-

UNIVERSITÄT FREIBURG
Prof. Dr. Leonhard Reindl
Lehrstuhl El. Mess- und Prüfverfahren

Signal Processing
Solution Exercise Nr. 2 SS2011
Date of issue: 19.05.11

Given the following measurement data:

U[V] 0.1 0.2 0.3 0.4 0.5


I[A] 0.3 0.43 0.61 0.65 0.75
U[V] 0.6 0.7 0.8 0.9 1
I[A] 0.9 0.85 1 1.2 1.25
U[V] 1.1 1.2 1.3 1.4 1.5
I[A] 1.35 1.5 1.62 1.7 1.76
U[V] 1.6 1.7 1.8 1.9 2
I[A] 1.85 2 2.1 2.23 2.28

Input parameter: U
Measured parameter: I

Exercise:

Calculate the exercises by hand and using MATLAB®!

1) Calculate the coefficients for the straight line approximation of the measured data, and draw
the calculated line in a diagram, as well as the measured data.

I [ A] = a + b ⋅ U [V ]

N
1 N N

1 N N

∑x yn n
−  ∑ xn ⋅ ∑ yn 
N  n =1 
a=  ∑ yn − ∑ xn b  b = n =1N n =1
(page 2.59)
N  n =1  1 N N

n =1
∑n =1
xn2 −  ∑ xn ⋅ ∑ xn 
N  n =1 n =1 

a = 0, 2269 und b = 1, 0377

Signal Processing, Solution Exercise Nr. 2 1/6


ALBERT-LUDWIGS-
UNIVERSITÄT FREIBURG

2) Smooth the series of the measurement using linear fitting with 3 points.

yn +1 + yn + yn −1
yn = (page 2.70)
3

U[V] 0.1 0.2 0.3 0.4 0.5


I_av[A] 0.4467 0.5633 0.67 0.7667
U[V] 0.6 0.7 0.8 0.9 1
I_av[A] 0.833 0.9167 1.0167 1.15 1.2667
U[V] 1.1 1.2 1.3 1.4 1.5
I_av[A] 1.3667 1.49 1.6067 1.6933 1.77
U[V] 1.6 1.7 1.8 1.9 2
I_av[A] 1.87 1.9833 2.11 2.2033

Signal Processing, Solution Exercise Nr. 2 2/6


ALBERT-LUDWIGS-
UNIVERSITÄT FREIBURG

3) Calculate the gradient of the smoothed data.

yn +1 − yn −1
yn′ = (page 2.75)
2h

U[V] 0.1 0.2 0.3 0.4 0.5


I_steig[A] 1.1167 1.0167 0.8167
U[V] 0.6 0.7 0.8 0.9 1
I_steig[A] 0.75 0.9167 1.1667 1.25 1.0833
U[V] 1.1 1.2 1.3 1.4 1.5
I_steig[A] 1.1667 1.2 1.167 0.8167 0.8833
U[V] 1.6 1.7 1.8 1.9 2
I_steig[A] 1.0667 1.2 1.1

average: I_steig_av = 1.0342

Signal Processing, Solution Exercise Nr. 2 3/6


ALBERT-LUDWIGS-
UNIVERSITÄT FREIBURG

4) Calculate the area under the original series of the measurement


using Kepler’s barrel rule.

Kepler’s barrel rule (page 2.81) is applicable only for an odd number of measuring points!

yn + 4 yn +1 + yn + 2
Kn = 2 ⋅ h ⋅ with n=1,3,5,…,17
6

n 1 3 5 7 9 11 13 15 17

Kn 0,0877 0,132 0,1733 0,2017 0,2517 0,299 0,3393 0,372 0,421

Trapezium rule (page 2.79) for the rest points (measuring point 19 – 20):

y19 + y20
A=h = 0, 2255
2

Total area:

Atotal = ∑ K n + A = 2,5032

Signal Processing, Solution Exercise Nr. 2 4/6


ALBERT-LUDWIGS-
MATLAB/Scilab solution: UNIVERSITÄT FREIBURG

u=(0.1:0.1:2);
i=[0.3 0.43 0.61 0.65 0.75 0.9 0.85 1 1.2 1.25 1.35 1.5 1.62 1.7 1.76 1.85 2
2.1 2.23 2.28];
n=length(u);
plot(u,i,'*');
hold on; % scilab: set(gca(),"auto_clear","off");
grid on; % scilab: set(gca(),"grid",[1 1]);

% ex 1:
XY=u*i';
X_Y=1/length(u)*sum(u)*sum(i);
X2=sum(u.^2); % oder X2=u*u'
X_2=1/length(u)*sum(u)*sum(u);
b=(XY-X_Y)/(X2-X_2);
a=1/n*(sum(i)-b*sum(u));

p=polyfit(u,i,1);
i_fit=p(1).*u+p(2);
plot(u,i_fit,'r');

% scilab solution:
% function y=FF(x,p),y=p(1)*x+p(2),endfunction
% function e=G(p,z),
% y=z(1),x=z(2);
% e=y-FF(x,p),
% endfunction
% [p,err]=datafit(G,[i;u],[1;0])

% ex 2:
i_a = zeros(1,n);
for k = 2:(n-1)
i_a(k)=(i(k-1)+i(k)+i(k+1))/3;
end
u_av=u(2:19);
i_av=i_a(2:19);
plot(u_av,i_av,'m'); % with magenta color

% ex 3:
n_iav=length(i_av);
i_grad = zeros(1,n_iav);
for k = 2:(n_iav-1)
i_grad(k)=(i_av(k+1)-i_av(k-1))/0.2;
end
i_grad_average=1/16*sum(i_grad(2:17));

% alternative solution with polyfit


p_av=polyfit(u_av,i_av,1);
i_grad_av=p_av(1);

% ex 4
K2=zeros(1,(n-2));

for k=1:2:(n-2)
%Kepler's barrel rule for measuring points 1- 19
K2(k)=(0.1/3)*(i(k)+4*i(k+1)+i(k+2));
%Trapezium rule for last two measuring points (19-20)

Signal Processing, Solution Exercise Nr. 2 5/6


K2(19)=0.1*(i(19)/2+i(20)/2); ALBERT-LUDWIGS-
UNIVERSITÄT FREIBURG
end

% sum all of separate bars


K2_total=sum(K2);

Matlab to Scilab convert:


http://www.scilab.org/product/dic-mat-sci/M2SCI_doc.htm

Signal Processing, Solution Exercise Nr. 2 6/6