1

I intend to plot multiple Power Spectral Densities on the same graph. I am using the following to plot the power spectral density for a single signal.

hss = dsp.SpectrumAnalyzer('SampleRate', Fs); 
step(hss,rx);
release(hss);

However, if I were to plot another signal in the same spectrum analyzer using hold on doesn't seem to help

hss = dsp.SpectrumAnalyzer('SampleRate', Fs); 
step(hss,rx); hold on;
step(hss,tx);
release(hss);

Could someone guide me on how to go about with this.

EDIT: Here's a snippet of my code:

Fs = 12e6;
data = randi([0 1],1000,1);
%% OQPSK Modulate data
hMod = comm.OQPSKModulator('BitInput',true); 
tx = step(hMod, data);
%% Add noise
hAWGN = comm.AWGNChannel('EbNo',2);
rx = step(hAWGN, tx);

Now I need a way to plot the PSD of both tx and rx in the same graph.

techenthu
  • 158
  • 11
smyslov
  • 1,279
  • 1
  • 8
  • 29
  • One way the "hold on" command would work is if you were calling plot() with the frequency and psd vectors. – willpower2727 Jun 30 '15 at 12:51
  • I did not understand what you meant @willpower2727. I have already tried using `hold on` but i think it would work only in case of `plot()` or `semilog() `but not in case of `step()` – smyslov Jun 30 '15 at 12:57
  • Yes I think "hold on" may not work for step(). Can you post a more complete example of your code? Like maybe with a sample data, Fs? – willpower2727 Jun 30 '15 at 13:05
  • edited my question @willpower2727 – smyslov Jun 30 '15 at 13:43
  • @ smyslov awesome, thanks, is the variable "chip_sequence" defined above? is it an input option? When I try to run your code it cannot tell what chip_sequence is. – willpower2727 Jun 30 '15 at 13:57
  • My bad. I've edited my code. It should have been data instead of chip_sequence. – smyslov Jun 30 '15 at 14:07

2 Answers2

1

Ok I think I've figure it out, you need to pass in more than one data to the same step call like so:

Fs = 12e6;
hss = dsp.SpectrumAnalyzer('SampleRate', Fs); 
data = randi([0 1],2000,1);%I had to increase the # of points
%% OQPSK Modulate data
hMod = comm.OQPSKModulator('BitInput',true); 
tx = step(hMod, data);
%% Add noise
hAWGN = comm.AWGNChannel('EbNo',2);
rx = step(hAWGN, tx);

%This is the line that makes it work, passing in a matrix of input data
step(hss,[rx tx]);

enter image description here

willpower2727
  • 769
  • 2
  • 8
  • 23
0

You can use the below code in Matlab.

assume you have two signal, signal1, and signal2.

rmc = lteRMCDL('R.0');
[signal1,~,info] = lteRMCDLTool(rmc,[1;0;0;1]); %

signal2 = 100*signal1;

scope = dsp.SpectrumAnalyzer;
scope.PlotAsTwoSidedSpectrum = true;
scope.SampleRate = info.SamplingRate; 

% You should replace your samplerate whit info.samplerate

scope([signal1 signal2])