Finding power spectral density using MATLAB,

In summary, the conversation discussed generating random unary and bi-polar sequences using Matlab at a period of Tb=1s and oversampling each sequence by a rate of 4. The code for generating the sequences and oversampling them was provided, along with the correct method for calculating and displaying the PSD. The problem of the PSD appearing flat at high frequencies was also addressed.
  • #1
geft
148
0
Question:
Using Matlab, generate random unary and bi-polar sequences of period Tb=1s, over-sample each sequence by a rate of 4, calculate and display their PSD.

It took me way too long to generate proper unary sequences. I have yet to figure out how to code bipolar sequences.

Here is the code I came up with. I don't understand half of it and the result doesn't look correct. The problem is that the psd appears completely flat at 0 amplitude at high frequencies.

Code:
h = commsrc.pattern('SamplingFrequency', 1, 'SamplesPerSymbol', 10, 'PulseType', 'NRZ', 'OutputLevels', [0 1], 'DataPattern', 'PRBS5');
x = generate(h, 1000);                    
plot(x)

Hpsd = dspdata.psd(x, 'SpectrumType', 'Twosided', 'CenterDC', true, 'Fs', 4);
plot(Hpsd)
 
Physics news on Phys.org
  • #2


First of all, great job on generating the unary sequences! It can definitely be a bit tricky to figure out at first. As for the bipolar sequences, here is some code that should help you generate them:

% Generate bipolar sequence of length 1000
bipolar = 2*randi([0,1], 1, 1000)-1;
% Plot the sequence
plot(bipolar)

Now, to oversample the sequences by a rate of 4, you can simply use the "upsample" function in Matlab:

% Upsample unary sequence by a rate of 4
unary_upsampled = upsample(unary, 4);
% Upsample bipolar sequence by a rate of 4
bipolar_upsampled = upsample(bipolar, 4);

To calculate and display the PSD, you can use the "periodogram" function in Matlab:

% Calculate PSD of unary sequence
[unary_psd, f] = periodogram(unary_upsampled, hamming(length(unary_upsampled)), length(unary_upsampled)*4, 1);
% Plot PSD
plot(f, unary_psd)

% Calculate PSD of bipolar sequence
[bipolar_psd, f] = periodogram(bipolar_upsampled, hamming(length(bipolar_upsampled)), length(bipolar_upsampled)*4, 1);
% Plot PSD
plot(f, bipolar_psd)

This should give you the correct PSD plot for both the unary and bipolar sequences. Hope this helps!
 

FAQ: Finding power spectral density using MATLAB,

1. What is power spectral density?

Power spectral density is a measure of the power of a signal at different frequencies. It is used to analyze the frequency content of a signal and is often used in fields such as signal processing and communications.

2. How is power spectral density calculated?

Power spectral density is typically calculated using Fourier transform methods, such as the Fast Fourier Transform (FFT), in software programs like MATLAB. The signal is divided into smaller segments, and the FFT is applied to each segment to obtain a spectrum. The power spectral density is then calculated by averaging the squared magnitude of the FFT results.

3. What is the difference between power spectral density and energy spectral density?

Power spectral density measures the power of a signal at different frequencies, while energy spectral density measures the energy of a signal at different frequencies. Power spectral density takes into account the amplitude of the signal, while energy spectral density does not.

4. How can power spectral density be used in data analysis?

Power spectral density can be used to identify patterns or frequencies in data that may not be visible in the time domain. It can also be used to filter out noise or unwanted frequencies from a signal. In addition, power spectral density can be used to compare signals and identify similarities or differences in their frequency content.

5. Are there any limitations or considerations when using MATLAB to calculate power spectral density?

Some potential limitations to consider when using MATLAB to calculate power spectral density include the size and quality of the data set, the choice of window function, and potential artifacts or distortions in the data. It is important to carefully select appropriate parameters and techniques for the specific data being analyzed to ensure accurate results.

Similar threads

Replies
1
Views
1K
Replies
1
Views
4K
Replies
8
Views
800
Replies
1
Views
3K
Replies
3
Views
2K
Replies
15
Views
2K
Back
Top