Merge pull request #64 from ltcptgeneral/brian

Moved my file to src
This commit is contained in:
bgt002 2021-12-12 18:35:38 -08:00 committed by GitHub
commit 12a95b359c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,8 @@
function x = generate_pulse(amplitude, frequency, phase, fs, duration, duty) function x = generate_pulse(amplitude, frequency, phase, fs, duration, duty)
% GENERATE_puse: returns a matrix of sampled pulse wave % GENERATE_pulse: returns a matrix of sampled pulse wave
% CONTRIBUTORS: % CONTRIBUTORS:
% Brian Tran: Created the wave % Brian Tran: Creator
% DOCUMENTATION: % DOCUMENTATION:
% phase shift is in number of periods % phase shift is in number of periods
@ -13,21 +13,13 @@ function x = generate_pulse(amplitude, frequency, phase, fs, duration, duty)
% initialize local variables from input arguments % initialize local variables from input arguments
n = fs * duration; % number of samples (length of matrix) n = fs * duration; % number of samples (length of matrix)
dt = 1 / fs; % sampling period: time between two sample points dt = 1 / fs; % sampling period: time between two sample points
% initialize a one dimensional zero matrix to be populated % initialize a one dimensional zero matrix to be populated
x = zeros(1, n); x = zeros(1, n);
f0=1e+6; % 1MHz
Fs=3e+6;
Tf=0.001; % 1 millisecond
t=0:1/Fs:Tf-1/Fs;
td=0.1; % duty cycle
A0=10; % 10 Volts
F=0;
N=1000; % Number of points
% populate the matrix % populate the matrix
for n = 1:N for i = 1:n
F=F+(1/n)*cos(n*2*pi*f0*t).*sin(n*pi*td); t = i*dt;
x(i) = amplitude * (sin(3*pi*frequency*t-phase)/(cos(3*pi*frequency*t-phase)))
end end
F=F*(2*A0/pi);
F=F+A0*td;
end end