Docsity

MATLAB Tutorial for Signal and Systems - ECE-314 Spring 2006, Lab Reports of Signals and Systems

Toggle sidebar
bg1
ECE-314 Spring 2006
Signal and Systems (Matlab Tutorial)
MATLAB (short for MATrix LABoratory)
A)
1- A=[1 2 3] 2- A=[1; 2; 3]
3- A=[1 2 3]' 4- A=[1; 2; 3]; A*A’
5- A=[1; 2; 3]; A.*A
B)
clear all; %clean the workspace
close all; %close all opened figures
clc; %clean the command window
time=[0 .5 1 1.5 2];
temp=[105 126 119 129 132];
figure, plot(time,temp)
figure, plot(time,temp,'*'),grid
figure, plot(time,temp,'-*'),grid
xlabel('time (s)')
ylabel('temperature')
Plot the function y=sin(2t) in matlab, with x-abscise labeled “Time(s)”
and the y-abscise “y(t)”; use t between 0 and 15 seconds.
clear all; %clean the workspace
close all; %close all opened figures
clc; %clean the command window
t=0:15
y=sin(2*t)
figure, plot(t,y),grid %figure, plot(t,y),grid
xlabel('time (s)')
ylabel('y(t)')
pf2

Partial preview of the text

Download MATLAB Tutorial for Signal and Systems - ECE-314 Spring 2006 and more Lab Reports Signals and Systems in PDF only on Docsity!

ECE-314 Spring 2006 Signal and Systems (Matlab Tutorial) MATLAB (short for MAT rix LAB oratory)

A)

1- A=[1 2 3] 2- A=[1; 2; 3]

3- A=[1 2 3]' 4- A=[1; 2; 3]; A*A’

5- A=[1; 2; 3]; A.*A

B)

clear all; %clean the workspace close all; %close all opened figures clc; %clean the command window time=[0 .5 1 1.5 2]; temp=[105 126 119 129 132]; figure, plot(time,temp) figure, plot(time,temp,''),grid figure, plot(time,temp,'-'),grid xlabel('time (s)') ylabel('temperature') Plot the function y=sin(2t) in matlab, with x-abscise labeled “Time(s)” and the y-abscise “y(t)”; use t between 0 and 15 seconds. clear all; %clean the workspace close all; %close all opened figures clc; %clean the command window t=0: y=sin(2*t) figure, plot(t,y),grid %figure, plot(t,y),grid xlabel('time (s)') ylabel('y(t)')

C)

Find y(n), for n=1,…,. y(n) is given by: y(n)=20+y(n-1) ; y(1)= Compute their sum clear all; close all; clc; y(1)=2; for n=2: y(n)=20+y(n-1); end y sum(y)

D) Function “stem”

help stem STEM Discrete sequence or "stem" plot. STEM(Y) plots the data sequence Y as stems from the x axis terminated with circles for the data value. STEM(X,Y) plots the data sequence Y at the values specified in X. STEM(...,'filled') produces a stem plot with filled markers. STEM(...,'LINESPEC') uses the linetype specifed for the stems and markers. See PLOT for possibilities. H = STEM(...) returns a vector of line handles. See also PLOT, BAR, STAIRS.