• Sonuç bulunamadı

Deadline: at 23.59

N/A
N/A
Protected

Academic year: 2022

Share "Deadline: at 23.59"

Copied!
5
0
0

Yükleniyor.... (view fulltext now)

Tam metin

(1)

Deadline: 23.12.2020 at 23.59 AYDIN ADNAN MENDERES UNIVERSITY

FACULTY OF ENGINEERING

ELECTRICAL AND ELECTRONICS ENGINEERING DEPARTMENT

“EE213-TRANSFORM TECHNIQUES WITH COMPUTER APPLICATIONS” HW#1

General Remarks:

✓ This assignment is not compulsory for you. If you choose to do the assignment, the assignment grade will be equivalent to an extra quiz grade. In other words, while calculating your pass grade, the grade you will get from this assignment may be among the five quiz grades you get the highest score.

✓ Write your code to m-file in Matlab’s Editor window.

✓ The m file you are going to create must not contain errors and it must be directly executable.

So, in the m file you have written and saved in the editor window, the upper right square should not be red colored (it should be green).

✓ The assignment will be held on ADUZEM portal, your solutions will also be uploaded on the portal, solutions sent by e-mail will not be accepted. Send your m file and theoretical solution file together compressed in rar/zip format via Aduzem portal.

✓ The deadline for submission is Wednesday, December 23rd, at 23:59. This time includes uploading your solutions to the system via the portal.

✓ Legal disciplinary action will be initiated against students who are determined to cheat in the assignment, and their grade will also be zero.

✓ Use the last digit in your student ID as A variable. If it is zero, use A=1 instead.

QUESTION

The discrete-time Fourier series (DTFS) is a frequency domain representation for periodic discrete-time sequences. For a signal x[n] with fundamental period 𝑁, the DTFS synthesis and analysis equations are given as,

i. In MATLAB environment, we can generate a rectangular signal using square function. The command A*square(2*pi*f*t,d) generates a square wave for the time vector t with frequency f and duty cycle d. You can read Matlab’s Help Documentation about square function for more information.

ii. Using the parameters 𝑓 = 2 and 𝑑 = %50, generate a rectangular signal 𝑥(𝑡) for a time vector of t = 0:0.1:1.

(2)

iii. The continuous signal 𝑥(𝑡) may be assumed as discrete and equal to 𝑥[𝑛]. For this, generate a discrete time vector n=0:M-1. Here M is the length of x or t vector.

iv. As the first figure, plot the discrete time sequence 𝑥[𝑛] versus n by using the proper command in Matlab which is for DT signals. Then observe the fundamental period 𝑁 of this DT signal.

v. Compute the DTFS coefficients 𝐶𝑘’s of 𝑥[𝑛] by using the above analysis equation. (This is the theoretical part. You must do this computation on your paper.)

vi. In Matlab, using the 𝐶𝑘’s you computed above and the DTFS synthesis equation, obtain the reconstruction of 𝑥[𝑛].

vii. There is also another way for obtaining DTFS coefficients and reconstruction of 𝑥[𝑛] in Matlab: The vector containing all DTFS coefficients, let’s call them 𝐶𝑘2’s, i.e.

𝐶𝑘2 = [𝐶0 𝐶1 𝐶2 ⋯ 𝐶𝑁−1] can be computed by 𝐶𝑘2= 1

𝑁𝑓𝑓𝑡(𝑥). Here, the length of 𝑓𝑓𝑡(𝑥) vector must be 𝑁 which is different from the length of x vector. You can read Matlab’s Help Documentation about fft function for more information about how to do this fft calculation.

And the original signal can be reconstructed with this way as: 𝑥̂ = 𝑁 × 𝑖𝑓𝑓𝑡(𝐶𝑘2). Obtain both DTFS coefficients and reconstruction of 𝑥[𝑛] by using this way.

viii. As the second figure, plot the original 𝑥[𝑛] signal (again), reconstruction of 𝑥[𝑛] obtained in step vi by using DTFS synthesis equation, and reconstruction of 𝑥[𝑛] obtained in step vii by using inverse FFT calculation as three sub plots. Don’t forget that these are all DT signals. Use the convenient title and axis labels in your plots.

ix. As the third figure, plot separately the magnitudes and the phases of DTFS coefficients obtained in step vi and step vii, as four sub plots. Don’t forget that these are all DT signals.

Use the convenient title and axis labels in your plots.

Good luck.

Dr. Adem ÜKTE

Solution for Step v:

𝑁 = 5 samples

(3)

𝐶𝑘 = 1

𝑁 ∑ 𝑥[𝑛]𝑒−𝑗𝑘𝜔0𝑛

𝑛=<𝑁>

= 1

𝑁 ∑ 𝑥[𝑛]𝑒−𝑗𝑘(2𝜋 𝑁⁄ )𝑛

𝑛=<𝑁>

= 1

𝑁∑ 𝑥[𝑛]𝑒−𝑗𝑘(2𝜋 5⁄ )𝑛

4

𝑛=0

=1

5[𝑥[0]𝑒−𝑗𝑘(2𝜋 5⁄ )0+ 𝑥[1]𝑒−𝑗𝑘(2𝜋 5⁄ )1+ 𝑥[2]𝑒−𝑗𝑘(2𝜋 5⁄ )2+ 𝑥[3]𝑒−𝑗𝑘(2𝜋 5⁄ )3+ 𝑥[4]𝑒−𝑗𝑘(2𝜋 5⁄ )4]

=6

5[1 + 𝑒𝑗𝑘2𝜋5 + 𝑒𝑗𝑘4𝜋5 − 𝑒𝑗𝑘6𝜋5 − 𝑒𝑗𝑘8𝜋5 ]

For DT signals, DTFS coefficients are periodic with the period 𝑁. So, the above 𝐶𝑘 coefficients are periodic with the period 𝑁 = 5, i.e. 𝐶0 = 𝐶5 = 𝐶10 or 𝐶2= 𝐶7= 𝐶12. Below, there is a sketch of magnitudes of 𝐶𝑘 coefficients for 0 ≤ 𝑘 ≤ 20.

N=5;A=6;

w0=2*pi/N;

k=0:20;

Ck=A/N*(1+exp(-1i*k*w0)+exp(-1i*k*2*w0)...

-exp(-1i*k*3*w0)-exp(-1i*k*4*w0));

figure,stem(k,abs(Ck)),xlabel('k'),ylabel('|C_k|'),...

title('Magnitude of DTFS Coefficients')

(4)

Matlab Code for Other Steps:

% EE213 2020-2021 Autumn

% HW 1 clear clc

close all

% Sürekli zaman (CT) eksenini belirtmek için kullanacağımız t vektörü:

t = 0:0.1:1;

f=2;d=50;A=6;

% ii: Toplam uzunluğu 1 saniye olan, frekansı 2 Hz dolayısıyla periyodu 0.5

% saniye olan, bu periyodun yarısında genliği A=6 diğer yarısında -6

% olan (duty cycle: %50) sürekli zamanlı (CT) bir kare dalga işareti

% üretelim:

x=A*square (2*pi*f*t,d);

% iii: Aslında Matlab'de sürekli zamanlı işaret diye bir şey yoktur. Bütün

% işaretler vektörlerle ifade edilir ve zaman ortamında ayrık değerler

% alır. Sadece biz onları plot komutuyla çizdirirken sürekli zamanlıymış

% gibi gösteriyoruz. Az önce oluşturduğumuz kare dalga işareti x'i ayrık

% zaman (DT) ortamında ifade etmek için bir ayrık zaman n vektörü

% oluşturacağız. x vektörünün eleman sayısına M dersek, n ayrık zaman

% vektörü 0 ile M-1 arasında tam sayı değerler almalıdır.

M=length(x);

n=0:M-1;

% iv: x vektörünü stem komutu ile yatay eksen n olacak şekilde çizdirirsek,

% ayrık zamanlı x[n] işareti için periyodun 5 örneğe eşit olduğunu

% gözlemleyebiliriz.

figure,stem(n,x),title('Original x[n] signal'),xlabel('n'),ylabel('x[n]') N=5;%Periyot

% vi: Adım v'te hesaplanan Ck katsayıları ve DTFS sentez bağıntısı

% kullanılarak x[n] işaretinin geriçatımının (reconstruction of x[n]) elde

% edilmesi.

w0=2*pi/N; % Temel açısal frekans (Fundamental angular frequency) sum_x=0; % x[n]'nin DTFS sentez toplamı için başlangıç değeri

% Daha önce derste yaptığımız CTFS alıştırmaları Practice 10 ve 11'de FS

% katsayılarını çizdirmemiz istenmediği için, her bir FS katsayısını

% depolamamız gerekmiyordu. Burada farklı olarak "Ck(k+1)=..." kullanımı

% ile toplamın her adımındaki FS katsayısını Ck isimli bir vektörün elemanı

% olarak depoluyoruz. Bu sayede FS katsayılarını daha sonra

% çizdirebileceğiz.

for k=0:N-1

Ck(k+1)=A/N*(1+exp(-1i*k*w0)+exp(-1i*k*2*w0)...

-exp(-1i*k*3*w0)-exp(-1i*k*4*w0)); % DTFS katsayıları Ck'lar sum_x=sum_x+Ck(k+1)*exp(1i*k*w0*n); % x[n] işaretinin geriçatımı end

% vii: Ck katsayılarının, alternatif bir yöntem olan fft ile elde edilmesi.

% Ayrıca x[n] işaretinin geriçatımı da ters fft ile elde edilmiştir.

% Burada Ck katsayıları N=5 örnek ile periyodik olduğu için, dolayısıyla 5

% adet Ck katsayısı elde edileceği için, x'in fft'si 5 örnek üzerinden

% hesaplanmıştır.

C=1/N*fft(x,N); % DTFS katsayıları Ck'lar x_hat=N*ifft(C); % x[n] işaretinin geriçatımı

% viii: Bu adımda istenen ayrık zamanlı işaretleri çizdireceğiz. Özgün x[n]

% işareti ve sentez toplam eşitliğini kullanarak elde ettiğimiz geriçatım

(5)

% x[n] işaretlerinin ikisi de M=11 örnekten oluşuyor ve daha önce bu

% işaretlerin ayrık zaman ekseninde kullanılmak üzere n=0:M-1 vektörünü

% oluşturmuştuk zaten. Fakat vii. adımda fft ve ters fft ile elde edilen

% geriçatım x[n] işareti N=5 örnekten oluşuyor. Bu işaret için yeni bir

% ayrık zaman vektörü olan nn'yi oluşturmalıyız. Çünkü bu işareti n

% vektörünü kullanarak çizmeye çalışırsak boyut uyumsuzluğu hatası alırız.

nn=0:N-1;

figure,subplot(311),stem(n,x),title('Original x[n] signal'),...

xlabel('n'),ylabel('x[n]') subplot(312),stem(n,sum_x),...

title('x[n] signal Reconstructed with DTFS Synt. Eq.'),...

xlabel('n'),ylabel('x[n]') subplot(313),stem(nn,x_hat),...

title('One perion of x[n] signal Reconstructed with IFFT'),...

xlabel('n'),ylabel('x[n]')

% ix: Bu adımda istenen DTFS katsayılarını çizdireceğiz. Aslında DTFS

% katsayıları Ck'lar da ayrık zamanlı işarettir. Sadece ayrık zaman ekseni

% n ile değil k ile gösterilir. Bilindiği gibi önceki adımlarda Ck

% katsayılarını (her iki yöntemde de) 5 adet olarak hesaplamıştık. Bu

% yüzden aşağıda bu Ck katsayılarını çizdirirken kullanacağımız ayrık zaman

% vektörü kk'yı tanımladık. k değişkenini daha önce kullandığımız için

% karışmaması açısından buna kk ismini verdik.

kk=0:N-1;

figure,subplot(221),stem(kk,abs(C)),...

title('Magnitude of DTFS Coeff. Obtained with IFFT'),...

xlabel('k'),ylabel('|C_k|') subplot(222),stem(kk,angle(C)),...

title('Phase of DTFS Coeff. Obtained with IFFT'),...

xlabel('k'),ylabel('<C_k') subplot(223),stem(kk,abs(Ck)),...

title('Magnitude of DTFS Coeff. Obtained with DTFS An. Eq.'),...

xlabel('k'),ylabel('|C_k|') subplot(224),stem(kk,angle(Ck)),...

title('Phase of DTFS Coeff. Obtained with DTFS An. Eq.'),...

xlabel('k'),ylabel('<C_k')

Referanslar

Benzer Belgeler

[r]

AIM: (a) to understand the initial rise and fractional glow techniques for the calculation of activation energy (E) and frequency factor (s) and (b) to calculate the E, s

 &#34;The legislative, or supreme authority, cannot assume to its self a power to rule by extemporary arbitrary decrees, but is bound to dispense justice, and decide the rights of

Yapılan bu çalışmada; güvenilirlik analizi yöntemlerinden biri olan &#34;kesme yöntemi&#34; kullanılarak çok elemanlı, kompleks sistemlerin güvenilirlik analizleri

2000 yılından 2004 yılına kadar genç erkekler arasındaki işsizliğin genç kadınlar arasındaki işsizlikten daha fazla olduğu görülmekte iken 2014 yılında bu

yüzyıl’ın en önemli düşünürlerinden Walter Benjamin’in çığır açan “Tekniğin Olanaklarıyla Yeniden Üretilebildiği Çağda Sanat Yapıtı” adlı eseri

amac›, 2007 y›l› Samsun ‹li perinatal mortalite h›- z›, erken ve geç neonatal mortalite h›z›, bebek mortalite h›z› ve ölüm nedenlerini, Samsun ‹l

Regarding examination of the relationship between anxiety sensitivity and severity of SAD in the pre- sent study, it was found that there was a positive correlation between