nass-simscape/Identification/identification_control.m

49 lines
1004 B
Mathematica
Raw Normal View History

%% Script Description
%
%%
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';
%% Y-Translation Stage
% Input/Output definition
io(1) = linio([mdl, '/Fnass_cart'],1,'input');
io(2) = linio([mdl, '/Sample'],1,'output');
% Run the linearization
G_f_to_d = linearize(mdl,io, 0);
% Input/Output names
G_f_to_d.InputName = {'Fy'};
G_f_to_d.OutputName = {'Dy'};
% Bode Plot of the linearized function
figure;
bode(G_f_to_d(2, 2), bode_opts)
%%
save('../mat/G_f_to_d.mat', 'G_f_to_d');