Code: clc clear all close all n1=input('Enter the time sample range of x'); x=input('Enter the sequence'); n2=input('Enter the time sample range of y'); y=input('Enter the sequence'); 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);
Hello Piyush Agrawal, you can refer the below videos -- Convolution in MATLAB(without conv function) | MATRIX Method | DSP ruclips.net/video/nzVPoc4PRgI/видео.html Plot the convolution result in MATLAB | CONVOLUTION using MATRIX method (Part 2) ruclips.net/video/nuvgtEzEM1c/видео.html Hope this will be helpful! Happy Learning :-)
can you let me know a bit how to do via functions ? I tried like this but error: function [y, r] = seqadd (n1,n2) u=min(min(n1),min(n2)); t=max(max(n1),max(n2)); r=u:1:t; temp=1; y1 = []; for i=1:length(r) if(r(i)max(n1)) y1=[y1 0]; else y1=[y1 x(temp)]; temp=temp+1; end end y2 = []; temp=1; for i=1:length(r) if(r(i)max(n2)) y2=[y2 0]; else y2=[y2 y(temp)]; temp=temp+1; end y=y1+y2; end
I have given the code in the comment section . Anyway giving here too , Happy Coding :-) clc clear all close all n1=input('Enter the time sample range of x'); x=input('Enter the sequence'); n2=input('Enter the time sample range of y'); y=input('Enter the sequence'); 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);
Code:
clc
clear all
close all
n1=input('Enter the time sample range of x');
x=input('Enter the sequence');
n2=input('Enter the time sample range of y');
y=input('Enter the sequence');
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);
Thankyou very much sir. You explained it really in a very easy way. 🙏🏻. Saved me from my lecturer 🙏🏻🙏🏻🙏🏻 .
Glad to hear that SANJEEV CHAVAN! Happy Learning :-)
thank you sir for your efforts , very well explained!
Glad the explanation was helpful to you Aditi Paretkar! Happy Learning :-)
Sir, can you please post and explain code for convolution of two discrete time signals
Hello Piyush Agrawal, you can refer the below videos --
Convolution in MATLAB(without conv function) | MATRIX Method | DSP
ruclips.net/video/nzVPoc4PRgI/видео.html
Plot the convolution result in MATLAB | CONVOLUTION using MATRIX method (Part 2)
ruclips.net/video/nuvgtEzEM1c/видео.html
Hope this will be helpful! Happy Learning :-)
@@KnowledgeAmplifier1 Thanks a lot sir for timely response
@@piyushagrawal6448 no problem ! Happy Learning
Thank you so much for this, you saved my life
Welcome Corinne Garcia
. Happy Learning :-)
can you let me know a bit how to do via functions ?
I tried like this but error:
function [y, r] = seqadd (n1,n2)
u=min(min(n1),min(n2));
t=max(max(n1),max(n2));
r=u:1:t;
temp=1;
y1 = [];
for i=1:length(r)
if(r(i)max(n1))
y1=[y1 0];
else
y1=[y1 x(temp)];
temp=temp+1;
end
end
y2 = [];
temp=1;
for i=1:length(r)
if(r(i)max(n2))
y2=[y2 0];
else
y2=[y2 y(temp)];
temp=temp+1;
end
y=y1+y2;
end
Is this addition of two discrete time signals or two digital signals?
Can u pls provide the code for a sampling signal
Hi sir ty for the video, i've a question, how can we do it with multiplication, what changes we make?
refer this video----ruclips.net/video/26wr4XDg36o/видео.html
hope this will be helpful.
can you give signal multiplication and division code
Hello gokul , you can refer this video :
ruclips.net/video/26wr4XDg36o/видео.html
Hope this will be helpful ! Happy Learning :-)
thanks .. can u pls provide code for this signal
Find convolution between x1[n] = (0.5^(n-2) u [n-2] )and
X2 [n] = u [n+2] .
It shows error x(temp) undefined x and y
Give x & y properly
Can u plz explain how z1=[z1 x(temp)] are equal??
It will put the x(temp) value in z1 array , working like concatenation
Bro here is not working
Show invalid index
(Y1,r)=add(x1,n1,x2,n2) am using this one in scilab
Hi
Can u explain how to add continous signals having different time range?
Same code you can apply for adding continuous signal of different range as in Computer Everything is discrete only , nothing can be continuous :-)
Nice
Thanks Arijit . Happy Coding :-)
Gg
no offense just asking btw
Code?
I have given the code in the comment section . Anyway giving here too , Happy Coding :-)
clc
clear all
close all
n1=input('Enter the time sample range of x');
x=input('Enter the sequence');
n2=input('Enter the time sample range of y');
y=input('Enter the sequence');
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);
😭😭
why you talking like you scolding me?