I need to break down a continuous Gaussian
pulse into 50 discrete parts
so I can use each of the 50 individual amplitudes in calculations. Here is what I've tried:
% Gauss pulse discretisation
tg = 20*10^(-3); % pulse duration [sec]
B1 = 1; % max amplitude [muT]
t = -tg/2:tg/50:tg/2; % sampling times
sd = 0.25; % pulse standard deviation
% pulse shape
p = B1*exp(-((t-tg/2).^2)/(2*sd.^2));
plot(t,p);
However, the plot looks nothing like a Gaussian pulse of 20ms in duration
! Is there a problem with how the sampling time
is defined? For example if the sampling time
is defined as
t = -1:tg/50:1
then the pulse does look like a Gaussian but it is broken down in 5001 parts. Could someone please point me in the right direction?
In order for your Gaussian to look like a Gaussian when you plot it, you need to make sure that you: (1) sample it around it's center, (2) your sampling interval is much smaller than the standard deviation (SD), and (3) you sample at least 2 or 3 SDs to each side, so you can see the decay. So in your example, since the Gaussian is centered around tg\2
, and since your SD is sd = 0.25
(btw the SD sets the pulse duration, not tg
), extend the sampling interval, using the SD as a measure (and not tg
), and move it so it is centered around the mean. It is easier to do all this using linspace
:
t = linspace(-3*sd, 3*sd, 50) + tg\2;
If you further want a 20msec pulse duration, make sd
in the order of 20msec, and not tg
. Also note that "duration" is really a matter of definition for a Gaussian, as it extends to +- infinity. You have to define something like "pulse duration is from -2 SDs to +2 SDs", which means the effective pulse duration is defined according to how much the tail decayed.
% Gauss pulse discretisation
tg = 0; % pulse center [sec]
B1 = 1; % max amplitude [muT]
sd = .5*20*10^(-3);% half the pulse duration (msec)
t = tg/2 + linspace(-3*sd,3*sd,50);
% pulse shape
p = B1*exp(-((t-tg/2).^2)/(2*sd.^2));
plot(t,p,'.-');