MATLAB Answers

Adding and generation of shot noise to a gaussian chirp signal.

7 views (last 30 days)
majid
majid on 15 May 2021
Commented: majid on 16 May 2021
Hi,
How can i adding shot noise to the gaussian chirp signal?
signal codes :
clc; clear; close all;
%--------------------------------------------------------------
fs = 1e3; dt = 1/fs; t = 0:dt:22.5e-3; % signal evaluation time
f1 = 29.25e6; f2 = 30.75e6;
c = (f2-f1)/(t(end)-t(1));
n = (-511:512)'; % Timeline
sigmas = exp(log(2):.3:log(200)); % Scales
w = exp(-.5*(n.^2)*sigmas.^(-2)); % Window Function
% Gaussian Chirp
chirps = w.*cos(n*sigmas.^(-1)*2*pi*5 + (c/2)*(n/sigmas').^2);
x = abs(chirps(:, 15)); % base signal
figure; plot(x); title('bidirectional gaussian chirp signal')
xlabel('Time(s)'); ylabel('Amplitude'); axis tight
%--------------------------------------------------------------
%adding shot noise
y = []; num_itter = 30; % number of itterations
for i = 1:num_itter
% append
y = [y; x];
end
Y = zeros(size(t)); Y(1:length(y)) = y;
figure; plot(t, abs(Y)); title('the final signal') axis tight
%//////////////////////////////////////////////////////////////////////////////////////////////////////
i write another code for generating this chirp gaussian signal but i can add shot noise to it:
clear all; clc
%--------------------------------------------------------------
% chirp signal generation
fs=1e3; t=0:1/fs:1;
f1=0; f2=20;
a=(f2-f1)/(t(end)-t(1)); f=f1+a*t;
x=cos(2*pi*f.*t);
subplot(2,1,1); plot(t,x); title(['down chirp signal']); xlabel('Time(s)'); ylabel('Amplitude');
% gaussian pulse generation
sigma=0.1; t1=-0.5:1/fs:0.5;
variance=sigma^2; w=1/(sqrt(2*pi*variance))*(exp(-t1.^2/(2*variance)));
subplot(2,1,2) plot(t1,w,'b'); title(['Gaussian Pulse \sigma=', num2str(sigma),'s']);
xlabel('Time(s)'); ylabel('Amplitude');
% gaussian chirp pulse generation
figure; xw = w(:) .* x(:);
plot(t,abs(xw)) xlim([0 1])\ xlabel('Time(s)'); ylabel('Amplitude');
title(['gaussian down chirp signal']);
%adding shot noise
y = []; num_itter = 32; % number of itterations
for i = 1:num_itter
% append
y = [y; xw];
end
T=0:1/fs:32.1; Y = zeros(size(T)); Y(1:length(y)) = y;
figure; plot(T,abs( Y));
title('the transmitting signal') xlabel('Time(s)'); ylabel('Amplitude');
axis tight
please help me!!!
thanks,Majid.

Answers (1)

Mathieu NOE
Mathieu NOE on 16 May 2021
hello
minor bug fixed in the last lines (see comments ) - it's the time vector definition (length) was incorrect
%--------------------------------------------------------------
% chirp signal generation
fs=1e3; t=0:1/fs:1;
f1=0; f2=20;
a=(f2-f1)/(t(end)-t(1)); f=f1+a*t;
x=cos(2*pi*f.*t);
subplot(2,1,1); plot(t,x); title(['down chirp signal']); xlabel('Time(s)'); ylabel('Amplitude');
% gaussian pulse generation
sigma=0.1; t1=-0.5:1/fs:0.5;
variance=sigma^2; w=1/(sqrt(2*pi*variance))*(exp(-t1.^2/(2*variance)));
subplot(2,1,2) ;plot(t1,w,'b'); title(['Gaussian Pulse \sigma=', num2str(sigma),'s']);
xlabel('Time(s)'); ylabel('Amplitude');
% gaussian chirp pulse generation
figure; xw = w(:) .* x(:);
plot(t,abs(xw));
xlim([0 1]); xlabel('Time(s)'); ylabel('Amplitude');
title(['gaussian down chirp signal']);
%adding shot noise
y = []; num_itter = 32; % number of itterations
for i = 1:num_itter
% append
y = [y; xw];
end
T=(0:length(y)-1) *1/fs; % time axis fixed
% Y = zeros(size(T)); Y(1:length(y)) = y; % no need for this line
figure; plot(T,abs(y));
title('the transmitting signal') ;
xlabel('Time(s)'); ylabel('Amplitude');
axis tight
  5 Comments
majid
majid on 16 May 2021
thank you!
I saw these codes before but I cant add it to my signal.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!