Convolution of 2 summed signals

MrAl

Joined Jun 17, 2014
13,720
Here, I moved the actual question here https://forum.allaboutcircuits.com/threads/issues-representing-signal.144007/ since the one in this post was replied. The problem is , if I take the results that I got and try to represent the signal I will get different results from what you're saying ( -t^2 + 3*t -2.25 is the first part of my signal which would be concave parabola and my graphic wouldnt look correct if i'd do that )


I did the convolution in matlab. And it should look like : first portion a convex parabola then a concave one then another convex one to end it right ?

Hi,

Ok let's do a different example then and you can use your experience to apply it to your original problem.

The only difference is the pulse runs from t=2 to t=3 seconds as shown in the attachment.

See if you can duplicate these waveforms, or at least the first blip.
 

Attachments

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hi,

Ok let's do a different example then and you can use your experience to apply it to your original problem.

The only difference is the pulse runs from t=2 to t=3 seconds as shown in the attachment.

See if you can duplicate these waveforms, or at least the first blip.
I don't get it .. is my result wrong ? the equation
 
Last edited:

MrAl

Joined Jun 17, 2014
13,720
I don't get it .. is my result wrong ? the equation
Hello again,

It does look wrong, but can you do the second example too? That may work out better for you.

I get this up to the exponential part for your original problem:
(1/s^3)*[e^((3*s)/2)-e^(-(3*s)/2)-3*e^(s/2)+3*e^(-s/2)]

and in floats:
(1/s^3)*[e^(1.5*s)-e^(-1.5*s)-3*e^(0.5*s)+3*e^(-0.5*s)]

Did you get that?

That is after:
(M*M)*M

not ((M*M)*M)*M.
 

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hello again,

It does look wrong, but can you do the second example too? That may work out better for you.

I get this up to the exponential part for your original problem:
(1/s^3)*[e^((3*s)/2)-e^(-(3*s)/2)-3*e^(s/2)+3*e^(-s/2)]

and in floats:
(1/s^3)*[e^(1.5*s)-e^(-1.5*s)-3*e^(0.5*s)+3*e^(-0.5*s)]

Did you get that?

That is after:
(M*M)*M

not ((M*M)*M)*M.
Yes, I got that
 

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hi,

You sure? Then what happened to the two constants "3" in two of the expressions in your inverse transform?
You're right, first time I did it another way and missed the constants. This is how I did it and it matches your results :







Edit : and with those results I get the wrong signal representation
 

MrAl

Joined Jun 17, 2014
13,720
You're right, first time I did it another way and missed the constants. This is how I did it and it matches your results :







Edit : and with those results I get the wrong signal representation
Hi,

How are you checking the signal representation?
DId you use Matlab for the whole problem or just part like you are doing now?

Also, remember the solution is only valid from the smallest value to the next smallest value if you only plot the first interval. I am not sure how you are plotting this, so i thought i would mention this. Perhaps you can show your plot so far.
So if you got values of -1.5, -0.5, +0.5, and +1.5, and only want to plot the first interval that is fine, but it is only valid from -1.5 to -0.5, so perhaps try plotting that ONE alone and see if it matches your Matlab.
I cant see how this could be wrong then unless you did something different in Matlab, that's the only way, unless Matlab is wrong somehow for this problem.
 

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hi,

How are you checking the signal representation?
DId you use Matlab for the whole problem or just part like you are doing now?

Also, remember the solution is only valid from the smallest value to the next smallest value if you only plot the first interval. I am not sure how you are plotting this, so i thought i would mention this. Perhaps you can show your plot so far.
So if you got values of -1.5, -0.5, +0.5, and +1.5, and only want to plot the first interval that is fine, but ti's only valid from -1.5 to -0.5, so perhaps try plotting that ONE alone and see if it matches your Matlab.
I cant see how this could be wrong then unless you did something different in Matlab, that's the only way, unless Matlab is wrong somehow for this problem.
I only used matlab to get the final picture. I'm plotting it like this : I did the inverse laplace of that equation and it resulted 2z(t) = (t+1.5)^2 * u(t+1.5) - 3*(t+0.5)^2 * u(t+0.5) + 3*(t-0.5)^2*u(t-0.5) - (t-1.5)^2*u(t-1.5) where * is product operator
and then I ordered it : 2z(t) = - (t-1.5)^2*u(t-1.5) + 3*(t-0.5)^2*u(t-0.5) - 3*(t+0.5)^2 * u(t+0.5) + (t+1.5)^2 * u(t+1.5) and took it by intervals :
for the first interval -1.5<t<-0.5 it would be - (t-1.5)^2 , for the 2nd interval -0.5<t<+0.5 it would be - (t-1.5)^2 + 3*(t-0.5)^2*u(t-0.5) and so on... isn't that how I should plot it ?
 

MrAl

Joined Jun 17, 2014
13,720
I only used matlab to get the final picture. I'm plotting it like this : I did the inverse laplace of that equation and it resulted 2z(t) = (t+1.5)^2 * u(t+1.5) - 3*(t+0.5)^2 * u(t+0.5) + 3*(t-0.5)^2*u(t-0.5) - (t-1.5)^2*u(t-1.5) where * is product operator
and then I ordered it : 2z(t) = - (t-1.5)^2*u(t-1.5) + 3*(t-0.5)^2*u(t-0.5) - 3*(t+0.5)^2 * u(t+0.5) + (t+1.5)^2 * u(t+1.5) and took it by intervals :
for the first interval -1.5<t<-0.5 it would be - (t-1.5)^2 , for the 2nd interval -0.5<t<+0.5 it would be - (t-1.5)^2 + 3*(t-0.5)^2*u(t-0.5) and so on... isn't that how I should plot it ?
Hi,

Let's do one interval at a time.

The transform we use is:
((t-a)^2*u(t-a))/2

and so the factor e^(1.5*s)/s^3 transforms into:
((t+1.5)^2*u(t+1.5))/2

and this is 'turned on' at t=-1.5 seconds.

Is that what you got?

The other little thing here is that the time shift theorem is always quoted as requiring that a>=0 and for this problem we have a<0 sometimes.

Try the other example and see if you can reproduce at least a few of those waves.

One thing i cant do is speak for Matlab because i dont use it. You might ask someone who does use it to try to reproduce your Matlab results.
 
Last edited:

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hi,

Let's do one interval at a time.

The transform we use is:
((t-a)^2*u(t-a))/2

and so the factor e^(1.5*s) transforms into:
((t+1.5)^2*u(t+1.5))/2

and this is 'turned on' at t=-1.5 seconds.

Is that what you got?

The other little thing here is that the time shift theorem is always quoted as requiring that a>=0 and for this problem we have a<0 sometimes.

Try the other example and see if you can reproduce at least a few of those waves.

One thing i cant do is speak for Matlab because i dont use it. You might ask someone who does use it to try to reproduce your Matlab results.
Shouldn't we take the (1/s^3)*e^(-1.5s) with t=-1.5s? How would you plot this signal fully ?
 

MrAl

Joined Jun 17, 2014
13,720
Shouldn't we take the (1/s^3)*e^(-1.5s) with t=-1.5s? How would you plot this signal fully ?
Hello,

u(t) turns 'on' at t=0. So u(t) using the "on/off" convention is like so:
u(t)=0, t<0
u(t)=1, t>=0

so obviously if we have t=-1.5 we have u(-1.5)=0.

If we want to plot from t=-1.5 to t=-0.5, we always have zero because u(t) is zero for t<0.

If we have a positive constant added to t, such as u(t+1), then when we plot from t=-1 the first point is:
y=u(t+1)
y=u(-1+1)
y=u(0)=1

and because now u(t+1)=1 for every time after that, y "stays" on (equal to 1) for times -1 to +infinity.

That's the basics to the unit step function, and so we see that a positive value like the +1 in (t+1) leads to a signal being enabled at the time value that is the negative of that positive value, and if we want to plot from some negative time value we have to start time t at a negative value.

If we have a function associated with the unit step that function gets enabled when u(x) becomes 1. So if we have:
y=f1(t)*u(t)

y is zero for t<0 and equal to f1(t) for t>=0. If we have say:
y=f1(t)*u(t+1)-f1(t)*u(t-2)

then the function f1(t) turns on at t=-1 and off at t=2.

Example, generate a pulse starting from t=-1 to t=+1.
u(t+1) becomes 1 at t=-1 so it turns the pulse on at t=-1 seconds.
u(t-1) becomes 1 at t=+1 so when subtracted from u(t+1) it turns the pulse off.
So the complete pulse signal is:
u(t+1)-u(t-1).

To plot the entire signal, we have to compute the values for all terms and add or subtract as they came out in the inverse transform. For example:
u(t+2)-u(t-2)+u(t+1)-u(t-1)

we start at t=-infinity and find that the first term turns 'on' at t=-2, then the third term turns on at t=-1, so we get first a signal y=1 at t=-2 then add another 1 at t=-1 to get y=2, then at t=+1 we subtract 1 then at t=+2 subtract another 1 so we get y=0 at t=2 and after, so we have a wave that looks like a pulse of amplitude 1 starting at t=-2 and then becomes higher with amplitude 2 at t=-1, then goes back down to 1 at t=+1, then down to zero at t=+2.

Try plotting that bi level pulse and see what you get.

Another quick pulse example:
u(t+5)-u(t+4)+u(t+3)-u(t-2)

This turns on at t=-5, then off at t=-4, then on again at t=-3, then off at t=+2, and remains off all the way up to +infinity.

Really though the example for (M*M)*M i gave you is better i think and it's not hard to do either. It's a good exercise too if you want to be sure you can do these fluently.

BTW, the transform we use is actually:
u(t-a)*((t-a)^2)/2

and so the factor e^(1.5*s)/s^3 transforms into:
u(t+1.5)*((t+1.5)^2)/2

because:
L^-1[e^(-a*s)*F(s)] => u(t-a)*f(t-a)

I forgot to show the denominator s^3 in one of my previous posts.
 
Last edited:

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hello,

u(t) turns 'on' at t=0. So u(t) using the "on/off" convention is like so:
u(t)=0, t<0
u(t)=1, t>=0

so obviously if we have t=-1.5 we have u(-1.5)=0.

If we want to plot from t=-1.5 to t=-0.5, we always have zero because u(t) is zero for t<0.

If we have a positive constant added to t, such as u(t+1), then when we plot from t=-1 the first point is:
y=u(t+1)
y=u(-1+1)
y=u(0)=1

and because now u(t+1)=1 for every time after that, y "stays" on (equal to 1) for times -1 to +infinity.

That's the basics to the unit step function, and so we see that a positive value like the +1 in (t+1) leads to a signal being enabled at the time value that is the negative of that positive value, and if we want to plot from some negative time value we have to start time t at a negative value.

If we have a function associated with the unit step that function gets enabled when u(x) becomes 1. So if we have:
y=f1(t)*u(t)

y is zero for t<0 and equal to f1(t) for t>=0. If we have say:
y=f1(t)*u(t+1)-f1(t)*u(t-2)

then the function f1(t) turns on at t=-1 and off at t=2.

Example, generate a pulse starting from t=-1 to t=+1.
u(t+1) becomes 1 at t=-1 so it turns the pulse on at t=-1 seconds.
u(t-1) becomes 1 at t=+1 so when subtracted from u(t+1) it turns the pulse off.
So the complete pulse signal is:
u(t+1)-u(t-1).

To plot the entire signal, we have to compute the values for all terms and add or subtract as they came out in the inverse transform. For example:
u(t+2)-u(t-2)+u(t+1)-u(t-1)

we start at t=-infinity and find that the first term turns 'on' at t=-2, then the third term turns on at t=-1, so we get first a signal y=1 at t=-2 then add another 1 at t=-1 to get y=2, then at t=+1 we subtract 1 then at t=+2 subtract another 1 so we get y=0 at t=2 and after, so we have a wave that looks like a pulse of amplitude 1 starting at t=-2 and then becomes higher with amplitude 2 at t=-1, then goes back down to 1 at t=+1, then down to zero at t=+2.

Try plotting that bi level pulse and see what you get.

Another quick pulse example:
u(t+5)-u(t+4)+u(t+3)-u(t-2)

This turns on at t=-5, then off at t=-4, then on again at t=-3, then off at t=+2, and remains off all the way up to +infinity.

Really though the example for (M*M)*M i gave you is better i think and it's not hard to do either. It's a good exercise too if you want to be sure you can do these fluently.

BTW, the transform we use is actually:
u(t-a)*((t-a)^2)/2

and so the factor e^(1.5*s)/s^3 transforms into:
u(t+1.5)*((t+1.5)^2)/2

because:
L^-1[e^(-a*s)*F(s)] => u(t-a)*f(t-a)

I forgot to show the denominator s^3 in one of my previous posts.
You are right, thank you so much. I was indeed turning on the signals at the opposite times and that was my mistake. The signal now matches the one in the figure ( convex parabola on -1.5:-0.5 , concave on -0.5:+0.5 and convex on +0.5:+1.5 )
 

MrAl

Joined Jun 17, 2014
13,720
You are right, thank you so much. I was indeed turning on the signals at the opposite times and that was my mistake. The signal now matches the one in the figure ( convex parabola on -1.5:-0.5 , concave on -0.5:+0.5 and convex on +0.5:+1.5 )
Hi,

You're welcome.

I also plotted the function using continuous approximations for the unit steps and got the plot in the attachment. It closely matches the other example i gave you, the green plot, just time shifted. I show the other example times in green numbers on the bottom.

BTW, i would have called it concave up and concave down not convex and concave, because both terms by themselves do not imply any specific orientation.
 

Attachments

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Right, now I have another issue sadly. I started doing the 4th convolution ( q = m(t) * m(t) * m(t) * m(t) ) with the same LaPlace method.
The problem is on the matlab plot the signal starts at about -1.75 if im not wrong. But when I do the calculus with laplace transform ( Q(s) = M(s) x M(s) x M(s) x M(s) ) I get this :


Which would mean that the signal starts at -2 right ? Is my calculus wrong or where's the mistake ?

Matlab plot :
 

MrAl

Joined Jun 17, 2014
13,720
Right, now I have another issue sadly. I started doing the 4th convolution ( q = m(t) * m(t) * m(t) * m(t) ) with the same LaPlace method.
The problem is on the matlab plot the signal starts at about -1.75 if im not wrong. But when I do the calculus with laplace transform ( Q(s) = M(s) x M(s) x M(s) x M(s) ) I get this :


Which would mean that the signal starts at -2 right ? Is my calculus wrong or where's the mistake ?

Matlab plot :

Hello again,

Yes i got that exponential expression also.

What would expect for this problem is a plot like the second example i gave you, the wave just after the one we did. Shifting it, it would start at -2 like you said. I believe this one should start at -2 also, but the amplitude should not be as high as you show with Matlab. Is that scaled by 10^8 or something? That's way too high.

I did 23 convolutions and got a good result, but i did not do this one yet except for the second example with the multiple waves where the pulse is shifted in time.

I'll try to get back to this a little later...
 

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hello again,

Yes i got that exponential expression also.

What would expect for this problem is a plot like the second example i gave you, the wave just after the one we did. Shifting it, it would start at -2 like you said. I believe this one should start at -2 also, but the amplitude should not be as high as you show with Matlab. Is that scaled by 10^8 or something? That's way too high.

I did 23 convolutions and got a good result, but i did not do this one yet except for the second example with the multiple waves where the pulse is shifted in time.

I'll try to get back to this a little later...

Yes the amplitude is scaled somehow I don't know how to get it good yet but it shouldn't change the form of the signal which in matlab starts at -1.75 or something like that and it doesnt match my expression
 

MrAl

Joined Jun 17, 2014
13,720
Yes the amplitude is scaled somehow I don't know how to get it good yet but it shouldn't change the form of the signal which in matlab starts at -1.75 or something like that and it doesnt match my expression
Hi,

Yes just after -2.

Here's my plot after applying all the transforms.
Compare with Matlab, but you never answer my questions. I need to know the scaling on that Matlab plot.
 

Attachments

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hi,

Yes just after -2.

Here's my plot after applying all the transforms.
Compare with Matlab, but you never answer my questions. I need to know the scaling on that Matlab plot.
Here is the matlab code :
Code:
clear all;
clc;
Fs = 1000;
Ts = 1/Fs;

t=-1:Ts:1;

%u(t-0.5)
step = zeros(size(t));
step(t>=0.5) = -1;

figure
grid
subplot(3,2,1)
plot(t,step)
title ('u(t-0.5)')


%u(t+0.5)
step2 = zeros(size(t));
step2(t>=-0.5)= 1;


grid
subplot(3,2,2)
plot(t,step2)
title ('u(t+0.5)')

xt=step2+step;


subplot(3,1,3)
plot(t,xt)
title ('u(t+0.5)-u(t-0.5)')

y = conv(xt,xt);

t3 = -2 :Ts:2;

figure
subplot(2,1,1)
plot(t3,y)
title('first convolution')

z = conv (y,xt );

t4= -3:Ts:3;


subplot(2,1,2)
plot(t4,z)
title('second convolution')

q = conv(z,xt);
t5 = -4:Ts:4;

figure
plot(t5,q)
title('third convolution')
If you can figure out the scaling it'd be great . As I said im currently trying to figure that out. Regarding your plot, it starts closer to -1.5 ? And in the expression that resulted it still starts at -2.. so its further than my matlab plot.
 
Last edited:

MrAl

Joined Jun 17, 2014
13,720
Here is the matlab code :
Code:
clear all;
clc;
Fs = 1000;
Ts = 1/Fs;

t=-1:Ts:1;

%u(t-0.5)
step = zeros(size(t));
step(t>=0.5) = -1;

figure
grid
subplot(3,2,1)
plot(t,step)
title ('u(t-0.5)')


%u(t+0.5)
step2 = zeros(size(t));
step2(t>=-0.5)= 1;


grid
subplot(3,2,2)
plot(t,step2)
title ('u(t+0.5)')

xt=step2+step;


subplot(3,1,3)
plot(t,xt)
title ('u(t+0.5)-u(t-0.5)')

y = conv(xt,xt);

t3 = -2 :Ts:2;

figure
subplot(2,1,1)
plot(t3,y)
title('first convolution')

z = conv (y,xt );

t4= -3:Ts:3;


subplot(2,1,2)
plot(t4,z)
title('second convolution')

q = conv(z,xt);
t5 = -4:Ts:4;

figure
plot(t5,q)
title('third convolution')
If you can figure out the scaling it'd be great . As I said im currently trying to figure that out. Regarding your plot, it starts closer to -1.5 ? And in the expression that resulted it still starts at -2.. so its further than my matlab plot.

Hi,

Well as i said i dont have Matlab, but you could look in the help files probably and find out how it scales.

Also, the difference in 'starting point' is not that important because it looks like an illusion caused by the different graphic aspect ratios. When i change the aspect ratio of your Matlab plot it looks very much the same as my plot. I also use continuous approximations for the unit steps so there may be minor differences. Check out the Matlab plot you posted with the aspect ratio adjusted to be closer to what my plot had and compare with my plot again.

The Matlab scaling would be the same if we divided the numbers on the left by 10. So the top would be 0.7 just like in my plot. So instead of x10^8 at the top it should be x10^-1 at the top.

MatlabConvolution-1.gif

Looks more like mine now.
In any case, either plot should start just after -2 because that's the first unit step and the function kicks in at -2 not at -1.5 or -1.75 although it may have low amplitude at say -1.95 for example, but it will not be exactly zero at that point.
Graphical objects can sometimes be deceiving.
 
Last edited:

Thread Starter

AlexMak

Joined Jan 2, 2018
32
Hi,

Well as i said i dont have Matlab, but you could look in the help files probably and find out how it scales.

Also, the difference in 'starting point' is not that important because it looks like an illusion caused by the different graphic aspect ratios. When i change the aspect ratio of your Matlab plot it looks very much the same as my plot. I also use continuous approximations for the unit steps so there may be minor differences. Check out the Matlab plot you posted with the aspect ratio adjusted to be closer to what my plot had and compare with my plot again.

The Matlab scaling would be the same if we divided the numbers on the left by 10. So the top would be 0.7 just like in my plot. So instead of x10^8 at the top it should be x10^-1 at the top.

View attachment 143098

Looks more like mine now.
In any case, either plot should start just after -2 because that's the first unit step and the function kicks in at -2 not at -1.5 or -1.75 although it may have low amplitude at say -1.95 for example, but it will not be exactly zero at that point.
Graphical objects can sometimes be deceiving.

Alright, so the graphic is right and the equation is right aswell. I have one more problem now, I must turn these signals into frequency. Any ideea on how to do it ? especially z(t) and q(t)
 
Top