DEV Community

Gökhan ERGEN
Gökhan ERGEN

Posted on

Signal Visualization in Discrete-Time Domain

In this application, we analyze and visualize the discrete-time signal represented by the following function:

y(k)=5cos(2πf1​kTs​)−2sin(2πf2​kTs​)

where:

  • f1 and f2​ are the signal frequencies,
  • k represents the discrete-time index,
  • Ts​ is the sampling period.

The signal values were computed and visualized using both stem and line plots to illustrate its discrete and continuous representations. These graphs help in understanding the periodic behavior and frequency components of the signal in the time domain.
A dropdown menu labeled "Examples" has been added, allowing users to switch between different examples seamlessly. This feature enhances usability by providing quick access to various signal processing demonstrations.

Examples Dropdown

We can change the function parameters.

Image description

We will encounter an interface where you can configure settings and view the signal graphs.

Calculation Used In The App

Ts = 1/Fs
x = [0, 1, 2, … N]
y = [(5*np.cos(2*pi*f1s*k*Ts)-2*sin(2*pi*f2s*k*Ts)) foreach k in x]
power = np.power(y,2)
energy = np.sum(power)
rmse = np.sqrt(energy/self.N)
average = np.mean(y)
variance = (1/self.N)np.sum(np.power((y-average),2))
std = np.sqrt(variance)
median = np.median(y)
own_mean = mean_own(y)
own_rmse = rmse_own(y)
own_variance = variance_own(y, own_mean)
own_std = math.sqrt(own_variance)
own_median = median_own(y)
own_average_power = own_rmse
*2
own_energy = own_average_power*len(y)
To show as time
x = [i/fs foreach i in x]

Increasing N

If N increases, the signal sample time will also increase, resulting in a wider range of signals observed in the graph.

Image description

If fs increases, Ts will reduce. In this case, the signals we will be able to see in the graph will be limited.

Image description

Image description

When fs = 500 and N = 250 are the same, the graph appears identical to the case where fs = 200 and N = 100.
We can observe signal analyses in the table.

Github Link: https://github.com/gokhanergen-tech/dearpygui-signal-waveforms

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay