0% found this document useful (0 votes)
37 views2 pages

VLab 1

The Matlab code simulates the time response of a system to two different inputs. For the first input, a unit step, the code generates the response using a first-order transfer function. For the second input, a damped cosine signal, the code simulates the response using a second-order transfer function. Both cases plot the output vector y versus time to show the time domain response of the system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

VLab 1

The Matlab code simulates the time response of a system to two different inputs. For the first input, a unit step, the code generates the response using a first-order transfer function. For the second input, a damped cosine signal, the code simulates the response using a second-order transfer function. Both cases plot the output vector y versus time to show the time domain response of the system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Matlab Code:

clear all
tvec=0:0.01:20; %creates a time vector from 0 to 20seconds with 0.01second
intervals
u=tvec.^0;
%creates the unit step input
[t,y]=ode45(@tank_control,tvec,[0],[],u,tvec,'height'); %creates response
of transfer function and stores them in a vector y
plot(tvec,y) %Plots y vs time
xlabel('Time(s)')
ylabel('Output Value')
title('Time Response of system')

The plot shows the time response of a system to unit step input. The transfer function used was:

( )
( )

Matlab Code:
clear all
tvec=0:0.001:2; %creates a time vector from 0 to 2seconds with 0.001second
intervals
u=(exp(-(tvec.^2))).*cos(3.*tvec); %creates the input
[t,y]=ode45(@tank_control,tvec,[0],[],u,tvec,'height'); %creates response
of transfer function and stores them in a vector y
plot(tvec,y) %Plots y vs time
xlabel('Time(s)')
ylabel('Output Value')
title('Time Response of system')

The plot shows the time response of a system to input u. The transfer functions used were:

( )
( )
( )
( )

You might also like