Matlab: plotting one period of a discrete signal

In summary: This gave me the time at which the first cycle of the aliased signal should start.However, the vector only starts at the beginning of the cycle and doesn't go to the end.In summary, I am trying to plot the first period of a discrete signal, but I want to display the original continuous signal for the full 60 seconds. My problem is that I am finding it difficult to find the start point for the first cycle of the aliased signal.
  • #1
Steve Collins
46
0
I have a 3 rad/s sine wave that I am sampling every 2 seconds.

The slow sampling has created an alias of -0.14 rad/s.

I have plotted this over the top of the original continuous time signal, please see attachment.

My problem is that I only want to plot the first period of the discrete signal, i.e. end at 44.88 seconds, but I want to plot the original CT signal for the full 60 seconds.

I'm going around in circles and getting some strange results. Hopefully somebody out there can shed some light.

Cheers

Steve
 

Attachments

  • matlab PF.docx
    95.9 KB · Views: 243
Physics news on Phys.org
  • #2
Steve Collins said:
I have a 3 rad/s sine wave that I am sampling every 2 seconds.

The slow sampling has created an alias of -0.14 rad/s.

I have plotted this over the top of the original continuous time signal, please see attachment.

My problem is that I only want to plot the first period of the discrete signal, i.e. end at 44.88 seconds, but I want to plot the original CT signal for the full 60 seconds.

I'm going around in circles and getting some strange results. Hopefully somebody out there can shed some light.

Cheers

Steve

Are you doing this to illustrate aliasing on purpose? What is the context of this work? It seems like you can plot whatever you want -- what is the issue? Sorry if I'm missing the obvious... :smile:
 
  • #3
berkeman said:
Are you doing this to illustrate aliasing on purpose? What is the context of this work? It seems like you can plot whatever you want -- what is the issue? Sorry if I'm missing the obvious... :smile:


I'm in the process of making a GUI that prompts a user for signal frequency, sample time and length.

If the user enters a sampling rate that is insufficient I want to lay the first cycle of the aliased signal over the original CTsignal to, as you say, illustrate aliasing.

As you can see from my attachment I have successfully overlaid the aliased signal, but I would like to only display the primary period.
 
  • #4
I managed to sort my problem out…. sort of.

I found the time taken to make one revolution

Circle time= (1/frequency) x 2 x π

And then made a vector from zero to

circle time x (1/sampling time)
 
  • #5


Thank you for sharing your question and concerns. It seems like you are dealing with some issues related to sampling and aliasing in your signal processing. To address your problem, I would suggest taking a step back and reviewing the fundamentals of sampling and aliasing in discrete signals.

First, it is important to understand that sampling is the process of converting a continuous signal into a discrete signal by taking measurements at specific time intervals. This is usually done to make the signal easier to process and analyze. However, sampling can also introduce errors and distortions in the signal, such as the aliasing you have observed.

Aliasing occurs when the sampling frequency is not high enough to accurately capture the original continuous signal, resulting in a distorted representation of the signal. In your case, the sampling frequency of 2 seconds may not be high enough to capture the 3 rad/s sine wave accurately, causing the alias of -0.14 rad/s.

To address your issue of plotting only the first period of the discrete signal, you can use the "xlim" function in Matlab to specify the range of the x-axis for your plot. This will allow you to plot only the desired portion of the signal. However, keep in mind that this will not change the underlying issue of aliasing in your signal.

To prevent aliasing, you can increase the sampling frequency or use a low-pass filter before sampling to remove high-frequency components of the signal. This will ensure that the sampled signal accurately represents the original continuous signal.

I hope this helps to shed some light on your situation. It is always important to have a good understanding of the fundamentals when dealing with signal processing to avoid unexpected results. Good luck with your research!
 

Related to Matlab: plotting one period of a discrete signal

What is a discrete signal?

A discrete signal is a type of signal that is defined only at discrete points in time or space. This means that the signal only has values at specific intervals, rather than being continuous.

What is the purpose of plotting one period of a discrete signal?

Plotting one period of a discrete signal allows us to visualize the behavior of the signal over a specific interval. This can help us understand the characteristics and patterns of the signal more clearly.

How do I plot one period of a discrete signal in Matlab?

To plot one period of a discrete signal in Matlab, you can use the "stem" function. This function plots a discrete signal as a series of vertical lines or stems, with the height of each stem representing the value of the signal at that point.

What is the difference between a continuous signal and a discrete signal?

A continuous signal is defined at every point in time or space, while a discrete signal is only defined at specific intervals. This means that a continuous signal can have an infinite number of values, while a discrete signal only has a finite number of values.

Can I plot multiple discrete signals on the same graph?

Yes, you can plot multiple discrete signals on the same graph in Matlab by using the "hold on" and "hold off" commands. This allows you to compare the behavior of different signals and see how they relate to each other.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
437
  • Engineering and Comp Sci Homework Help
Replies
6
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Electrical Engineering
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
876
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • General Math
Replies
1
Views
827
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top