Skip to content

Commit

Permalink
Add matlab scripts for running simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Jan 6, 2021
1 parent 3aab5c8 commit 3faadab
Show file tree
Hide file tree
Showing 17 changed files with 1,484 additions and 1 deletion.
29 changes: 29 additions & 0 deletions Matlab_Toolbox/Utilities/Af_HPF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function [dHPF,HPF] = Af_HPF(omega,zeta,DT,varargin)
%% Example Code
% omega = 2*pi*6; %rad/s
% HPF = tf(om^2,[1,2*zeta*omega,omega^2]);
% dHFP = c2d(LPF,DT);
%
% varargin to specify order

if isempty(varargin)
order = 2;
else
order = varargin{1};
end

if order == 2
HPF = tf([1,0,0],[1,2*zeta*omega,omega^2]);
elseif order > 2
[b,a] = butter(order,omega,'high','s');
HPF = tf(b,a);
else
HPF = tf([1,0],[1,omega]);
end

dHPF = c2d(HPF,DT,'tustin');

if 0
figure(881);
bode(HPF);
end
29 changes: 29 additions & 0 deletions Matlab_Toolbox/Utilities/Af_LPF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function [dLPF,LPF] = Af_LPF(omega,zeta,DT,varargin)
%% Example Code
% omega = 2*pi*6; %rad/s
% LPF = tf(om^2,[1,2*zeta*omega,omega^2]);
% dLFP = c2d(LPF,DT);
%
% varargin to specify order

if isempty(varargin)
order = 2;
else
order = varargin{1};
end

if order == 2
LPF = tf(omega^2,[1,2*zeta*omega,omega^2]);
elseif order > 2
[b,a] = butter(order,omega,'s');
LPF = tf(b,a);
else
LPF = tf(omega,[1,omega]);
end

dLPF = c2d(LPF,DT,'tustin');

if 0
figure(881);
bode(LPF);
end
Loading

0 comments on commit 3faadab

Please sign in to comment.