Combine a signal with AM noise
8 次查看(过去 30 天)
显示 更早的评论
i have a signal and i want to add some AM noise to it.
the signal looks like this:
the code for the signal is :
Fs = 1E+9;
L = 2E-6;
t = linspace(0, L*Fs, L*Fs+1)/Fs;
k = log(0.6)/0.2E-6;
s = -4*(exp(k*t) .* sin(2*pi*2.5/5E-7*t));
sd=s.*heaviside(t-0.5E-6);
figure
plot(t, sd,'r','linewidth',1)
grid
the AM noise i'm using made by this code:
duration = 3; % seconds
samplingRate = 8192; % per second
samplingInterval = 1 / samplingRate;
t = 1:samplingInterval:duration;
y1 = cos(2*pi*300*t); % signal
y2 = cos(2*pi*600000*t); % modulating signal (frequency = 600k Hz, adjust as desired)
y2 = rescale(y2,0.25,1); % modulation amplitude min/max factor
y = y1 .* y2; % create amplitude-modulated signal
% plot about 1 second of the signal (to show amplitude modulation)
plot(y(1:9000))
set(gca,'ylim', [-1.2, 1.2]);
i want an AM noise that looks like this one:
them merge the plots into one single plot so the signal gets interfered by AM noise
2 个评论
采纳的回答
Star Strider
2023-9-23
编辑:Star Strider
2023-9-23
The array sizes are not compatible, and the signals must be sampled at the same rate. That is the problem, because that would require ‘y’ to be upsampled to ‘Fs’ and that:
[yr,tr] = resample(y, t, Fs);
throws this error:
Requested 1x2000122071 (14.9GB) array exceeds maximum array size preference (5.0GB). This might cause MATLAB to become unresponsive.
You need to revise your code so that both vectors are the same sizes, will fit into available memory, and have the desired qualities. Then:
AM = (yr-min(yr(:))) .* sd;
should work to do the A3 (double sideband transmitted carrier) modulation. (I would also change the first ‘t’ to ‘t1’ and the second ‘t’ to ‘t2’ to avoid confusing or overwriting them.)
The plot-within-a-plot is not difficult. You can do that with —
Fs = 1E+9;
L = 2E-6;
t = linspace(0, L*Fs, L*Fs+1)/Fs;
k = log(0.6)/0.2E-6;
s = -4*(exp(k*t) .* sin(2*pi*2.5/5E-7*t));
sd=s.*heaviside(t-0.5E-6);
figure
plot(t, sd,'r','linewidth',1)
grid
y = sum(cos(1000*[300; 600000]*2*pi*t));
AM = (y-min(y(:))) .* sd; % DSB-TC
figure
plot(t, y)
grid
xlabel('Time [\mus]')
ylabel('Amplitude [mV]')
title('AM Radio Interference (‘QRM’)')
xlim([0 2E-7])
ylim([min(ylim) 1.5*max(ylim)])
Ax1 = gca;
pos1 = Ax1.Position;
Ax2 = axes;
Ax2.Position = pos1+[0.32 0.65 -0.35 -0.68];
plot(Ax2, t, AM)
grid
xlabel('Time [\mus]', 'FontSize',7)
ylabel('Amplitude [mV]', 'FontSize',7)
Human-created radio interference is designated in radiotelegraphy as ‘QRM’ while natural interference (‘static’, lightening,etc.), is designated ‘QRN’.
EDIT — (23 Sep 2023 at 16:33)
Changed signal code for second plot, added modulation.
.
2 个评论
Star Strider
2023-9-23
See my newly-edited code. I apparently posted it about the same time you posted your latest Comment.
You can use your signals or mine in the plots. All you need to change are the plot arguments to your signals to use them, although you might need to change the xlim call to fit your signals. That xlim call only affects the ‘outer’ plot, not the inset.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!