Commit 800a56e5 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

extended VC setup

parent b8a930c9
function [tf,h] = pb_tf(sys)
% PB_TF()
%
% PB_TF() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
clear h s N D;
syms h s N D;
n = sys.Numerator;
d = sys.Denominator;
N(s) = 0; D(s) = 0;
for iN = 1:length(n)
N(s) = N(s) + (n(iN)* s ^ (length(n)-iN));
end
for iD = 1:length(d)
D(s) = D(s) + (d(iD)* s ^ (length(d)-iD));
end
h(s) = N(s)/D(s);
tf = vpa(h,4);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function D = pb_iTF(y,varargin)
% PB_ITF()
%
% PB_ITF() ...
%
% See also PB_Y2X
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
%% Initialize
if nargin == 0; syms y A w t; y = A*sin(w*t); end
amplitude = pb_keyval('amplitude',varargin,1);
omega = pb_keyval('omega',varargin,1);
dur = pb_keyval('dur',varargin,30);
sr = pb_keyval('sr',varargin,10);
%% Body
x = pb_y2x(y);
T = 0:1/sr:dur;
xfun = matlabFunction(x); % x = F[y(t)]
yfun = matlabFunction(y); % y = A * sin(w*t)
D.tfun = x;
D.t = T;
D.x = xfun(amplitude,T,omega);
D.py = yfun(amplitude,T,omega);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function pb_systemIdentification()
function [sys] = pb_systemIdentification()
% PB_SYSTEMIDENTIFICATION()
%
% PB_SYSTEMIDENTIFICATION() ...
......
function x = pb_y2x(y,H)
% PB_Y2X(y, H)
%
% PB_Y2X() transforms the symbolic wanted output expression to a symbolic
% required input expression, using Laplace transformation and the system's
% transfer function.
%
% See also PB_ITF
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
syms s t x X Y
if nargin == 1
% if no tf was provided select default parameters (tf2 for VC model dat with ampl. 15).
syms H s N D
N(s) = 2.002*s + 0.01492;
D(s) = s^2 + 2.009*s + 0.0145;
H(s) = N/D;
end
Y(s) = laplace(y);
X(s) = Y(s)/H(s);
x = ilaplace(X(s));
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......@@ -9,7 +9,6 @@ function pb_nicegraph(varargin)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
%% Initialization: Define axes, colorschemes, & plots
fig = pb_keyval('fig',varargin,gcf);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment