hw 1

docx

School

New York University *

*We aren’t endorsed by this school

Course

6183

Subject

Mathematics

Date

Jan 9, 2024

Type

docx

Pages

5

Uploaded by MagistrateProton12881

Report
MATLAB HW #1 1.1) 1) Code % 1) n = -10 : 10; f = (n == 0); figure(1) stem (n,f) Output 2) Code % 1) n = -10 : 10; f = (n == 0); figure(1) stem (n,f) Output 3.
Code % 3a-e) % 3a n = -5 : 5; f=1-(1.*(n>=5)); subplot(3,2,1) figure(3) stem(n,f); xlabel( 'n' ); ylabel( 'f' ); title( 'f(n)' ); %3b g=n-(2.*(n-5).*(n>=5))-((n-10).*(n>=10)); subplot(3,2,2) stem(n,g); xlabel( 'n' ); ylabel( 'g' ); title( 'g(n)' ); %3c x=1.*(n==0)-2.*(n==4); subplot(3,2,3) stem(n,x); xlabel( 'n' ); ylabel( 'x' ); title( 'x(n)' ); %3d y=((0.9).^n).*(1-1.*(n>=20)); subplot(3,2,4) stem(n,y); xlabel( 'n' ); ylabel( 'y' ); title( 'y(n)' ); %3e v=cos(2*pi*n); subplot(3,2,5) stem(n,v); xlabel( 'n' ); ylabel( 'v' ); title( 'v(n)' ); Output
1.2 code % 1.2 % a f=[1 1 1 1 1]; g=[0 1 2 3 4 -5 -6 -7 -8 -9]; a=conv(f,f); figure(4) subplot(3,2,1) stem(a) xlabel( 'n' ) ylabel( 'f*f' ) title( 'convolution of f and f' ) % b f=[1 1 1 1 1]; g=[0 1 2 3 4 -5 -6 -7 -8 -9]; b=conv(f,conv(f,f)); subplot(3,2,2) stem(b) xlabel( 'n' ) ylabel( 'f*f*f' ) title( 'convolution of three f' ) % c f=[1 1 1 1 1]; g=[0 1 2 3 4 -5 -6 -7 -8 -9]; c=conv(f,g); subplot(3,2,3) stem(c) xlabel( 'n' ) ylabel( 'f*g' ) title( 'convolution of f and g' )
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
% d g=[0 1 2 3 4 -5 -6 -7 -8 -9]; delta=[1]; d=conv(g,delta); subplot(3,2,4) stem(d) xlabel( 'n' ) ylabel( 'g*delta' ) title( 'convolution of g and delta' ) % e g=[0 1 2 3 4 -5 -6 -7 -8 -9]; e=conv(g,g); subplot(3,2,5) stem(e) xlabel( 'n' ) ylabel( 'g*g' ) title( 'convolution of g and g' ) Output Questions Do you see any relationship between ? ( ? ) ? ( ? ) and ? ( ? ) ? There is no relationship, they are not the same. Compare ? ( ? ) with ? ( ? ) ? ( ? ) and with ? ( ? ) ? ( ? ) ? ( ? ). They are similar. The convolution of the three f is smaller. What happens as you repeatedly convolve this signal with itself? It provides triangular functions of different sizes. 3
Code %3 function [y]=myconv (x,h) lx=length(x); lh=length(h); y = zeros(1,lx+lh-1); for i = 1:lx for j = 1:lh y(j) = h(j)*x(i); end end end Output