EE341.01: MATLAB M-FILE FOR DEFINING A COMBINATION SIGNAL USING A COMPACT DEFINITION

This example shows a MATLAB M-file for defining a combination signal in a one line compact format and then plotting it.

MATLAB M-File example6.m:

%
% File Name: example6.m
%
% Description: This M-file is used to plot the combination signal
%
%              xv = 0.5 t^2 + 2t for 0<=t<=1
%                 = -0.5 t^2 + 3 for 0<=t<=2
%

t = 0.0:0.005:2.0;                           % define time vector
xv = (0.5*t.*t + 2*t).*(t>=0) - (0.5*t.*t + 2*t).*(t>=1) ...
     + (-0.5*t.*t + 3).*(t>=1);              % define signal in one line
                                             
plot(t,xv);                                  % plot signal
grid;
xlabel('time (seconds)');
ylabel('x(t)*v(t)');
title('EE341.01: Plot of x(t)*v(t) from Classroom Example');

MATLAB Plot Generated: