---
# System prepended metadata

title: My DSP Lab - 01

---

---
title: My DSP Lab - 01
---
# ELEC4621 DSP Lab 1
## Introduction
This article is to share the lab note and results for my DSP course at UNSW (ELEC4621)

## Lab
The task in lab 1 is to use DFT to analyze a set of discrete signal data and discuss the findings.

However, the signal analyzed in this lab is not a conventional electronic signal like the voltage, but a historical observation of solar activity (Fig.1). The number of sunspots is recorded from year 1818 to 2017. 

![](https://i.imgur.com/u2Gu08D.png =50%x)
>Fig.1 Solar activity 
>Reference: [What Is the Solar Cycle?](https://spaceplace.nasa.gov/solar-cycles/en/)


To analyze it, two methods are applied to the signal. The first is to apply FFT to the whole series of the signal of sunspots. The second method is to separate the data into several blocks (at least 40 years) and apply FFT to each of the blocks.  

![FLow chart](https://i.imgur.com/LQjOPOv.jpg "Flow chart" =50%x)
>Fig.2 Flow chart to analyze the data


![](https://i.imgur.com/vW7Lfzv.png "Sunspots" =60%x )
>Fig.3 Sunspots number from 1818 to 2017
>
## First Method
The first method applied is DFT to whole signal. The sampling frequency is one data per day so the sampling period is one day.
\begin{gather*}
f_s = 1\\
T_s = 1
\end{gather*}
By using FFT, the frequency spectrum would be,
![](https://i.imgur.com/BWt05CQ.png =60%x)
> Fig.4 Frequency spectrum in logarithmic scale

If we scale up,
![](https://i.imgur.com/U5xbmxW.png =60%x)
> Fig.5 Closer look of frequency spectrum

The original frequency of sunspots data is 

\begin{split}
f_{original} &= 0.000240575\\
T_{original} &= 1/0.000240575\\
&=4154.79(days)\\
&=11.388(years)
\end{split}



## Second Method
The second method is to separate signals into blocks. The time spanning for each of the blocks is 40 years.
With same process of applying FFT, the result would be,

![](https://i.imgur.com/WhqKEqm.png =200%x)
> Fig.6 Frequency spectrum for part of data

The original frequency of sunspots data is 
\begin{split}
f_{original} &= 0.000239742\\
T_{original} &= 1/0.000239742\\
&=4171.18(days)\\
&=11.427(years)
\end{split}

## Findings
From the two methods, the results are similar and their values are around 11 years. Comparing the literature source from nasa [What Is the Solar Cycle?](https://spaceplace.nasa.gov/solar-cycles/en/), the result matches the cycle of sunspot activity which is 11 years.

Although the results have small deviation in this lab, using only the small part of the signal to do DFT might cause problems for the frequency spectrum.

### Use part of the signal
The signal shown in Fig.7 has $f=2000$ in the first half and $f=4000$ in the second. What happened if we only do DFT for part of sampled data($f_s=8000$)? We might lose the frequency information for one of the frequencies, as shown in Fig.8 and Fig.9. 
![](https://i.imgur.com/g8P77Ad.jpg)
> Fig.7 Two signals with different frequencies concatenated


![](https://i.imgur.com/o4kKQLV.jpg =50%x)
> Fig.8 DFT for whole signal


![](https://i.imgur.com/8loOsIW.jpg =50%x)
> Fig.9 DFT for part of signal (t=0~2.5s)

## Appendix
My code: https://github.com/FrankHsu327/ELEC4621_Advance_Digital_Signal_Processing/tree/main/Lab1