function in MATLAB that will take a sequence x[n], and shift it to the left or to the right by a given number of samples. use the function written to find the sum of the results obtained by shifting x[n] to the right by 2 samples and and obtained by shifting x[n] to the left by 2 samples. kindly provide the codes🙏
Check this video please-->Signal addition in MATALB ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-cHb8Gsk2fFQ.html Now if you have the original signal and shifted one , you can add simply :-) For example , in the above case , if you want to add , the code will be like this--> n1=0:4; x=[0 1 2 3 3]; n2=n1-2; y=x; u=min(min(n1),min(n2)); t=max(max(n1),max(n2)); r=u:1:t; z1=[]; temp=1; for i=1:length(r) if(r(i)max(n1)) z1=[z1 0]; else z1=[z1 x(temp)]; temp=temp+1; end end z2=[]; temp=1; for i=1:length(r) if(r(i)max(n2)) z2=[z2 0]; else z2=[z2 y(temp)]; temp=temp+1; end end z=z1+z2; subplot(3,1,1); stem(r,z1); subplot(3,1,2); stem(r,z2); subplot(3,1,3); stem(r,z);
@@werewolfwaghela752 This is the code--> n1=-4:4; x=(n1>=0); n2=n1+1; y=x; u=min(min(n1),min(n2)); t=max(max(n1),max(n2)); r=u:1:t; z1=[]; temp=1; for i=1:length(r) if(r(i)max(n1)) z1=[z1 0]; else z1=[z1 x(temp)]; temp=temp+1; end end z2=[]; temp=1; for i=1:length(r) if(r(i)max(n2)) z2=[z2 0]; else z2=[z2 y(temp)]; temp=temp+1; end end z=z1+z2; subplot(3,1,1); stem(r,z1); subplot(3,1,2); stem(r,z2); subplot(3,1,3); stem(r,z);
I have explained in the video as N+2 but later I have shown the reverse case too , so for that I have used n-2 , watch the whole video please and then comment :-)
@@ninaddevdas6953 please watch the figure at 3:56 , I have done that ony , N-2 means delaying the signal , which means signal should move towards the positive axis , to timplement that in MATLAB , you have to write m=n+2