0% found this document useful (0 votes)
35 views7 pages

For End For End For For If Else If End End End End: % Seria Fourier

The document describes performing a Fourier series analysis on a signal. It defines the time and signal value arrays t and x. It then calculates the Fourier coefficients using a matrix inverse operation and plots the amplitude and phase of the first 9 harmonics. It also interpolates the original signal for plotting purposes. In summary, it performs a Fourier analysis to decompose a signal into its harmonic components.

Uploaded by

byzybyzy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views7 pages

For End For End For For If Else If End End End End: % Seria Fourier

The document describes performing a Fourier series analysis on a signal. It defines the time and signal value arrays t and x. It then calculates the Fourier coefficients using a matrix inverse operation and plots the amplitude and phase of the first 9 harmonics. It also interpolates the original signal for plotting purposes. In summary, it performs a Fourier analysis to decompose a signal into its harmonic components.

Uploaded by

byzybyzy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

% seria Fourier

clear
clc
t=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
x=[122.3,38.3,13.5,-45.2,-90.6,-160,-184,-211,-198,-164,-122,-39.7,14.9,46.6,89.2,160.8,182.8,210.4,195.2,162.2]
for i=1:19
b(i,1)=x(i);
end
for k=1:19
A(k,1)=1/2;
end
for j=1:19
for k=1:19
if (rem(k,2)==0)
A(j,k)=cos((k/2)*2*pi*50*t(j)*0.001);
else
if(k>1)
A(j,k)=sin((k-1)/2*2*pi*50*t(j)*0.001);
end
end
end
end
b
A
Y=inv(A)*b
% forma restransa
X0=Y(1)/2
j=1; % j ia valori de la 1 la 9
for k=2:19
if rem(k,2)==1
xk(j)=sqrt(Y(k-1)^2+Y(k)^2);
gamak(j)=atan(Y(k-1)/Y(k));
j=j+1;
end
end
xk
gamak
% desen
figure
armonica=[0,1,2,3,4,5,6,7,8,9]
bar(armonica,[X0,xk],0.7,'g')
figure
bar(armonica,[0,gamak],0.9,'y')
%interpolare
j=1;
for k=0:0.001:19
t_i(j)=k;

j=j+1;
end
x_i=interp1(t,x,t_i,'cubic');
figure
plot(t_i,x_i,'g')
grid
title('semnalul analogic')

200

150

100

50

-50

1.5

0.5

-0.5

-1

-1.5

semnalul analogic
250
200
150
100
50
0
-50
-100
-150
-200
-250

10

12

14

16

18

20

t=
Columns 1 through 18
0

10

11

12

13

14

15

16

17

Columns 19 through 20
18

19

x=
Columns 1 through 11
122.3000 38.3000 13.5000 -45.2000 -90.6000 -160.0000 -184.0000 -211.0000
-198.0000 -164.0000 -122.0000
Columns 12 through 20
-39.7000 -14.9000 46.6000 89.2000 160.8000 182.8000 210.4000 195.2000
162.2000
b=
122.3000
38.3000
13.5000
-45.2000
-90.6000
-160.0000
-184.0000
-211.0000
-198.0000
-164.0000
-122.0000
-39.7000
-14.9000
46.6000
89.2000
160.8000
182.8000
210.4000

195.2000
A=
Columns 1 through 10
0.5000
0.5000
0.0000
0.5000
-1.0000
0.5000
-0.0000
0.5000
1.0000
0.5000
0.0000
0.5000
-1.0000
0.5000
-0.0000
0.5000
1.0000
0.5000
0.0000
0.5000
-1.0000
0.5000
-0.0000
0.5000
1.0000
0.5000
0.0000
0.5000
-1.0000
0.5000
-0.0000
0.5000
1.0000
0.5000
-0.0000
0.5000
-1.0000

1.0000
0.9511

0 1.0000
0.3090 0.8090

0 1.0000
0 1.0000
0 1.0000
0.5878 0.5878 0.8090 0.3090 0.9511

0.8090

0.5878

0.3090

0.9511 -0.3090

0.9511 -0.8090

0.5878

0.8090 -0.3090

0.9511 -0.9511

0.3090 -0.8090 -0.5878

0.3090

0.9511 -0.8090

0.5878 -0.8090 -0.5878

-0.0000

1.0000 -1.0000 -0.0000 -0.0000 -1.0000

1.0000

0.0000

-0.3090

0.9511 -0.8090 -0.5878

0.8090 -0.5878

0.3090

0.9511

-0.5878

0.8090 -0.3090 -0.9511

0.9511

0.3090 -0.8090

0.5878

-0.8090

0.5878

0.3090 -0.9511

0.3090

0.9511 -0.8090 -0.5878

-0.9511

0.3090

0.8090 -0.5878 -0.5878

0.8090

0.3090 -0.9511

-1.0000 -0.0000

1.0000

0.0000 -1.0000

0.0000

1.0000

0.0000

-0.9511 -0.3090

0.8090

0.5878 -0.5878 -0.8090

0.3090

0.9511

-0.8090 -0.5878

0.3090

0.9511

0.3090 -0.9511 -0.8090

0.5878

-0.5878 -0.8090 -0.3090

0.9511

0.9511 -0.3090 -0.8090 -0.5878

-0.3090 -0.9511 -0.8090

0.5878

0.8090

0.5878

0.3090 -0.9511

-0.0000 -1.0000 -1.0000

0.0000

0.0000

1.0000

1.0000 -0.0000

0.3090 -0.9511 -0.8090 -0.5878 -0.8090

0.5878

0.3090

0.9511

0.5878 -0.8090 -0.3090 -0.9511 -0.9511 -0.3090 -0.8090

0.5878

0.8090 -0.5878

Columns 11 through 19

0.5878

0.3090 -0.9511

0.3090 -0.9511 -0.3090 -0.9511 -0.8090 -0.5878

0 1.0000
1.0000 -0.3090
0.0000 -0.8090
-1.0000 0.8090
-0.0000 0.3090
1.0000 -1.0000
0.0000 0.3090
-1.0000 0.8090
-0.0000 -0.8090
1.0000 -0.3090
0.0000 1.0000
-1.0000 -0.3090
-0.0000 -0.8090
1.0000 0.8090
0.0000 0.3090
-1.0000 -1.0000
-0.0000 0.3090
1.0000 0.8090
0.0000 -0.8090
Y=
-1.3000
121.6659
-154.5443
-0.6495
0.6231
-11.6033
-6.0283
0.0544
0.4878
0.9700
-5.0900
0.5245
0.2852
4.1498
-0.8959
0.8706
0.3803
6.9677
-7.6900
X0 =

0 1.0000
0 1.0000
0
0.9511 -0.5878 0.8090 -0.8090
-0.5878 -0.3090 -0.9511 0.3090
-0.5878 0.9511 0.3090 0.3090
0.9511 -0.8090 0.5878 -0.8090
0.0000 -0.0000 -1.0000 1.0000
-0.9511 0.8090 0.5878 -0.8090
0.5878 -0.9511 0.3090 0.3090
0.5878 0.3090 -0.9511 0.3090
-0.9511 0.5878 0.8090 -0.8090
-0.0000 -1.0000 0.0000 1.0000
0.9511 0.5878 -0.8090 -0.8090
-0.5878 0.3090 0.9511 0.3090
-0.5878 -0.9511 -0.3090 0.3090
0.9511 0.8090 -0.5878 -0.8090
0.0000 -0.0000 1.0000 1.0000
-0.9511 -0.8090 -0.5878 -0.8090
0.5878 0.9511 -0.3090 0.3090
0.5878 -0.3090 0.9511 0.3090

1.0000
0.5878
-0.9511
0.9511
-0.5878
0.0000
0.5878
-0.9511
0.9511
-0.5878
0.0000
0.5878
-0.9511
0.9511
-0.5878
-0.0000
0.5878
-0.9511
0.9511

0
-0.9511
0.8090
-0.5878
0.3090
0.0000
-0.3090
0.5878
-0.8090
0.9511
-1.0000
0.9511
-0.8090
0.5878
-0.3090
-0.0000
0.3090
-0.5878
0.8090

0.3090
-0.5878
0.8090
-0.9511
1.0000
-0.9511
0.8090
-0.5878
0.3090
0.0000
-0.3090
0.5878
-0.8090
0.9511
-1.0000
0.9511
-0.8090
0.5878

-0.6500
xk =
196.6889

0.9001 13.0759

0.4908

5.1816

0.5970

4.2454

0.9500 10.3771

gamak =
-0.6669 -0.8061

1.0916

0.1111 -0.1883

armonica =
0
>>

1.0727 -1.3582

1.1589 -0.7362

You might also like