Matlab 2 for hw 3

Matlab 2 for hw 3 - >>...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Astha Kalia 803791434 EE 102 Matlab Lee Homework #3-Matlab 1.) Task 1: Nconv script function [ y, ty ] = nconv( x, tx, h, th) % nconv performs a numerical approximation to the % continuous time convolution using matlab’s conv() % function % % [y, ty]= nconv(x, tx, h, th) % Input: % x -- inut signal vector % tx--times of the samples in x % h -- impulse response vector % th--times of the samples in h % % Outputs: % y --outputs signal vector, % length(y)=length(x)+length(h)-1 % ty -- times of the samples in y % % The command plot(tx,h,th,h,ty,y) should properly % display your functions dt = 0.01; % Multiplied by dt to approximate the continous integral y = conv(x,h)*dt; ty = (tx(1)+th(1))+ [0:length(y)-1].*dt; % plot End Homework Assignment 3-Problem #5 >> tx= [1:0.01:2]; >> x = 2.*ones(size(tx)); >> th=tx; >> h=linspace(0, 2, length(th)); >> dt=0.01; >> y=conv(x, h)*dt; >> ty= (tx(1)+th(1))+[0:length(y)-1].*dt;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >> >> figure; >> subplot(3,1,1); >> plot(tx, x, 'LineWidth', 2); >> axis([-1 5 0 3]); >> xlabel('Time(s)'); >> ylabel('Amplitude'); >> title('x(t)'); >> grid on; >> >> subplot(3,1,2); >> plot(th, h, 'LineWidth', 2); >> axis([-1 5 0 3]); >> xlabel('Time(s)'); >> ylabel('Amplitude'); >> title('h(t)'); >> grid on; >> >> subplot(3, 1,3); >> plot(ty, y, 'LineWidth', 2); >> axis([-1 5 0 3]); >> xlabel('Time(s)'); >> ylabel('Amplitude'); >> title('y(t)'); >> grid on; 2.) Task 2: >> dt=0.01; >> t=-.5: dt:0.5; >> x= ones(size(t)); >> [y, ty]= nconv(x, t, x, t); >> plot(ty, y); 3.) Task 3: >> dt=0.01; >> t=-.5: dt:0.5; >> x= ones(size(t)); >> [y, ty]= nconv(x, t, x, t); >> plot(ty, y); >> [y, ty]= nconv(y, ty, x, t); >> plot(ty, y); >> xlabel('Time(s)'); >> ylabel('Amplitude'); >> title('y(t)');...
View Full Document

This note was uploaded on 03/30/2012 for the course ELEC ENGR 102 taught by Professor Lee during the Fall '11 term at UCLA.

Page1 / 3

Matlab 2 for hw 3 - >>...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online