78 lines
1.8 KiB
Matlab
78 lines
1.8 KiB
Matlab
%% Script Description
|
|
% Run an identification of each stage from input to output
|
|
% Save all computed transfer functions into one .mat file
|
|
|
|
%%
|
|
clear;
|
|
close all;
|
|
clc
|
|
|
|
%% Define options for bode plots
|
|
bode_opts = bodeoptions;
|
|
|
|
bode_opts.Title.FontSize = 12;
|
|
bode_opts.XLabel.FontSize = 12;
|
|
bode_opts.YLabel.FontSize = 12;
|
|
bode_opts.FreqUnits = 'Hz';
|
|
bode_opts.MagUnits = 'abs';
|
|
bode_opts.MagScale = 'log';
|
|
bode_opts.PhaseWrapping = 'on';
|
|
bode_opts.PhaseVisible = 'on';
|
|
|
|
%% Options for preprocessing the identified transfer functions
|
|
f_low = 10;
|
|
f_high = 1000;
|
|
|
|
%% Options for Linearized
|
|
options = linearizeOptions;
|
|
options.SampleTime = 0;
|
|
|
|
%% Name of the Simulink File
|
|
mdl = 'Assemblage';
|
|
|
|
%% Micro-Hexapod
|
|
% Input/Output definition
|
|
io(1) = linio([mdl, '/Fhexa_cart'],1,'input');
|
|
io(2) = linio([mdl, '/Micro_Hexapod'],1,'output');
|
|
|
|
% Run the linearization
|
|
G_micro_hexapod_raw = linearize(mdl,io, 0);
|
|
|
|
% Post-process the linearized function
|
|
G_micro_hexapod = preprocessIdTf(G_micro_hexapod_raw, f_low, f_high);
|
|
|
|
% Input/Output names
|
|
G_micro_hexapod.InputName = {'Fy'};
|
|
G_micro_hexapod.OutputName = {'Dy'};
|
|
|
|
% Bode Plot of the linearized function
|
|
figure;
|
|
bode(G_micro_hexapod(1, 1), bode_opts)
|
|
|
|
%% Granite
|
|
% Input/Output definition
|
|
io(1) = linio([mdl, '/Granite_F'],1,'input');
|
|
io(2) = linio([mdl, '/Granite'],1,'output');
|
|
|
|
% Run the linearization
|
|
G_micro_hexapod_raw = linearize(mdl,io, 0);
|
|
|
|
% Post-process the linearized function
|
|
G_micro_hexapod = preprocessIdTf(G_micro_hexapod_raw, f_low, f_high);
|
|
|
|
% Input/Output names
|
|
G_micro_hexapod.InputName = {'Fy'};
|
|
G_micro_hexapod.OutputName = {'Dy'};
|
|
|
|
% Bode Plot of the linearized function
|
|
figure;
|
|
bode(G_micro_hexapod(1, 1), bode_opts)
|
|
|
|
|
|
%% Functions
|
|
function G = preprocessIdTf(G0, f_low, f_high)
|
|
[~,G1] = freqsep(G0, 2*pi*f_low);
|
|
[G2,~] = freqsep(G1, 2*pi*f_high);
|
|
G = minreal(G2);
|
|
end
|