%
% File: flexcinit.m
% Controller initialization for flexible beam simulation
% Created by Marc Bodson. Last revised: 05/23/25
%
% Controller design
%
% TO BE FILLED
%
% Controller discrete-time implementation and initialization
%
sysc=tf(numc,denc);[ac,bc,cc,dc]=ssdata(c2d(sysc,dt,'zoh'));
syscf=tf(numcf,dencf);[af,bf,cf,df]=ssdata(c2d(syscf,dt,'zoh'));
xc=zeros(length(bc),1);xf=zeros(length(bf),1);
%
% Set-up of the simulation and storage variables
%
tmax=6;                       % Simulation time
npoints=round(tmax/dt);       % Number of simulation points
ts=zeros(npoints,1);          % Time variable
phis=zeros(npoints,1);        % Beam tip angle
phirefs=zeros(npoints,1);     % Beam tip angle reference
ths=zeros(npoints,1);         % Shaft angle
imotors=zeros(npoints,1);     % Motor current
ip=1;                         % Initial index for storage