%File: HeaterControl.m%Revised November 1, 2004 by Clark Radcliffeecho on%------------------------------------------------%% This script computes and displays the step     %% responses of a 1st order heater control system %% with varying proportional Feedback Gains.      %% (Remember to enter gain vector in brackets)    %%------------------------------------------------%
echo off%zero data:%gp=[];tau=[];kp=[];student_name=[];GcGp=[];Gh=[];system=[];%Get Student Name:student_name = input('Enter your last name, student number = ','s');if isempty(student_name); student_name='NoName'; end%Get Plant Parametersgp =  input('Enter the plant open-loop gain (1.376): ');if isempty(gp); gp=1.376; endtau = input('Enter the plant time constant (0.09576): ');if isempty(tau); tau=0.09576; end%Get control gainskp=input('Enter the proportional gain vector, kp([1 2 3]): ');if isempty(kp); kp=[1 2 3]; end    
% Define the TRANSFER FUNCTION of the CONTROL*PLANT% Define a family of open loop TF's using% the family of control gains in the vector kp
GcGp=tf(zeros([1 1 length(kp) 1]));for i=1:length(kp)    GcGp(:,:,i)=tf([kp(i)*gp],[tau 1]);end%Choose a feedback gain of 'UNITY'
Gh=1;
%The PLANT and the FEEDBACK are to be connected 
%  with the "feedback" command to get the closed-loop 'SYSTEM'
% Remember that " SYSTEM = PLANT + FEEDBACK "% This defines a family of closed-loop transfer functions% of the form T(s)= kp*gp/{tau*s + (1 + kp*gp)}system=feedback(GcGp,Gh)
%Compute a family of step responses using the family of TF'sstep(system)V = AXIS; V(4)=1; AXIS(V);    %Set Ymax = 1.0
title([student_name, ': Temperature Response Ratio for gains, kp = [', num2str(kp), ']']);
xlabel('Time (sec)');
ylabel('Step Response Ratio: Output/Input');
