Code covered by the BSD License  

Highlights from
Marine Automatics

image thumbnail

Marine Automatics

by

 

28 Oct 2010 (Updated )

Simulation models of marine automatics elements library for MATLAB/Simulink

Demo2c1.m
% Maximum gain of the P controller calculation for Demo no. 2
% (C) Copyright by Mateusz Blonski, Szczecin 2010

% Create complex argument s
s=tf('s');

% Get parameters of the motor
paramm=str2double(get_param('Demo2/DC Motor with magnet1','MaskValues'));

% Set the transfer function of the motor
Gm=paramm(1)/((paramm(4)*paramm(5))*s^3+(paramm(3)*paramm(5)+paramm(4)*paramm(6))*s^2+(paramm(3)*paramm(6)+paramm(1)*paramm(2))*s);

% Get parameters of the displacement transducer
paramd=str2double(get_param('Demo2/Displacement transducer1','MaskValues'));

% Set the gain coefficient of the displacement transducer
skdt=paramd(4)/paramd(3);

% Set the transfer function of the open loop system without gain of the controller
G=Gm*skdt;

% Calculate stability margin
margin=allmargin(G);

% Show Nyquist's plot
nyquist(G*margin.GainMargin);

% Show message box
msgbox(['Maximum gain of the controller for stable linear system is: ' int2str(margin.GainMargin)],'Demo no. 2','help');

Contact us