Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lab5:
- clc;
- clear all;
- close all;
- x=input('Enter the sequence of 1st signal:');
- n1=input('Enter the time sample:');
- y=input('Enter the sequence of 2nd signal:');
- n2=input('Enter the time sample');
- z=input('Enter the sequence of 3rd signal:');
- n3=input('Enter the time sample:');
- u=min(min(n1),min(n2));
- t=max(max(n1),max(n2));
- n=u:1:t;
- z1=[];
- temp=1;
- for i=1:length(n)
- if (n(i)<min(n1) || n(i)>max(n1)) %make length of 1st signal equal to n with padding 0;
- z1=[z1 0];
- else
- z1=[z1 x(temp)];%otherwise take same element
- temp=temp+1;
- end
- end
- z2=[];
- temp=1;
- for i=1:length(n)
- if (n(i)<min(n2) || n(i)>max(n2))
- z2=[z2 0];
- else
- z2=[z2 y(temp)];
- temp=temp+1;
- end
- end
- subplot(5,1,1);
- stem(n1,x);
- subplot(5,1,2);
- stem(n2,y);
- %Addition
- p=z1+z2;
- subplot(5,1,3);
- stem(n,p);
- subplot(5,1,4);
- stem(n3,z);
- %folding
- subplot(5,1,5);
- stem(-n3,z);
- lab6:
- clc;
- clear all;
- close all;
- n1=input('Enter the time range of 1st signal:');
- x=input('Enter the sequence:');
- n2=input('Enter the time range of 2nd signal:');
- y=input('Enter the sequence:');
- n3=input('Enter the time range of 3rd signal:');
- z=input('Enter the sequence:');
- u=min(min(n1),min(n2));
- t=max(max(n1),max(n2));
- n=u:1:t;
- z1=[];
- temp=1;
- for i=1:length(n)
- if (n(i)<min(n1) || n(i)>max(n1))
- z1=[z1 0];
- else
- z1=[z1 x(temp)];
- temp=temp+1;
- end
- end
- z2=[];
- temp=1;
- for i=1:length(n)
- if (n(i)<min(n2) || n(i)>max(n2))
- z2=[z2 0];
- else
- z2=[z2 y(temp)];
- temp=temp+1;
- end
- end
- %multiplication
- m=z1.*z2;
- subplot(5,1,1);
- stem(n1,x);
- subplot(5,1,2);
- stem(n2,y);
- subplot(5,1,3);
- stem(n,m);
- subplot(5,1,4);
- stem(n3,x);
- %right shift with 2 unit
- n3=n3+2;
- subplot(5,1,5);
- stem(n3,x);
- lab10:
- clc;
- clear all;
- close all;
- x=input('Enter the sequence:');
- n=input('Enter the time range:');
- N=input('Enter the number of point:');
- if N>length(x)
- for i=1:N-length(x)
- x=[x 0];
- end
- end
- X=[];
- xx=0;
- for n=0:N-1
- for k=0:N-1
- xx=xx+x(k+1)*exp(j*2*pi*n*k/N);
- end
- X=[X 1/N*(xx)];
- xx=0;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement