i need to plot equation w(t) = symsum(dir​ac(t-k*Ts)​,k,-Inf,In​f) in discrete time signal.

i need to write this equation in matlab and plot them as well as discrete time signal. i already coded them with:
t=-5:0.25:5;
syms k
w(t) = symsum(dirac(t-k*Ts),k,-Inf,Inf);
Unrecognized function or variable 'Ts'.
stem(t,w(t))
but i didnt get the answer

 Risposta accettata

That must be a pulse train with interval of Ts. You need to decide your Ts. An example can be like below.
t=-5:0.25:5;
Ts = 1;
syms k
w = symsum(dirac(t-k*Ts),k,-Inf,Inf);
w = double(w);
idx = w == Inf;
w(idx) = 1;
stem(t,w)

5 Commenti

Hi 檮杌
I realize that you're making a plot in the spirit of the code in the question, but the plot is misleading, IMO, because it implies that the signal w(t) is only defined at the times indicated by the symbols. But w(t) is a continuous-time function, so maybe something like shown below, with the same understanding that the heights of the vertical lines represent the coeffiecients of the impulses. Also, I'd use a different symbol on the stems that looks more like an arrow, which in my experience is more common for representing a delta function (whereas the 'o' symbol is more commonly used to represent discrete time signals, again in my experience).
t=-5:0.25:5;
Ts = 1;
syms k
w = symsum(dirac(t-k*Ts),k,-Inf,Inf);
w = double(w);
idx = w == Inf;
w(idx) = 1;
figure
plot(t,0*t,'b')
hold on
stem(t(idx),w(idx),'b^')
ylim([-0.1 1.1])
But the original poster specified discrete time signal. The form with the sum from negative infinity to positive infinity is what you would expect if a continuous time function had been discretized... discretized forgetting that dirac delta is not a function.
Hi Walter,
Actually the OP specified two things: "plot them as well as discrete time signal." I assumed that this should be properly read as "plot it as well as [a] discrete time signal" where the "it" is referring to w(t), which is a continuous-time signal using typical variable naming conventions, i.e., the variable t refers to continuous time. I don't know what "discrete time signal" is desired to be plotted as no discrete-time signal is specified in the problem statement. Because the OP code specified the range -5 < t < 5, I assumed that defines the limits of the plot, i.e., the "draw graphical representation of w(t) over the interval -5 < t < 5."
"The form with the sum from negative infinity to positive infinity is what you would expect if a continuous time function had been discretized"
I don't know what you mean by this statement.
The defintion of w(t) as given is that of a continuous-time impulse train, which is a very important continuous time signal in developing the theory of sampling (which is what I assume you mean by "discretized"), but it's not itself a discrete-time signal.
t=-5:0.25:5; is the discrete time signal required by the user.
t = -5:0.25:5 does not define a discrete time signal. A discrete-time signal would be of the form
w[n] = ...
where the right hand side depend on n, and n in integer in the range -inf < n < inf.
If w(t) is a continuous-time signal, a discrete-time signal could be formed by sampling
w[n] = w(n*T) where T is a constant.
but sampling continuous-time signals that contain Dirac's may be a tricky business, and probably doesn't make any sense at all in this particular problem if T = Ts.

Accedi per commentare.

Più risposte (1)

Dirac delta is a distribution rather than a function.
It can be treated as a distribution in an integration, in which case the integral of C*dirac(X) over an interval is C if the interval includes X and is otherwise 0.
But you are not doing integration, you are doing summation. And when you do summation, the function C*dirac(X) is infinity * sin(C ) if X is exactly equal to 0 in the summation and is otherwise 0.
Hence, the summation w(t) is infinite if t-kTs is exactly 0 anywhere for integer k, and otherwise w(t) is 0. But you cannot plot infinity...
For continuous t and rational Ts then over t from -inf to +inf there would be an infinite number of those infinities. After all, if Ts = p/q for integer p and integer q, then when k becomes a multiple of q, k=r*q then the q would cancel, and k*Ts would be p*r for integer p and r and that would be satisfied when t becomes that p*r . If Ts is irrational then with continuous time you could still satisfy at selected irrational t.
With discrete time over an infinite interval, the p*r logic still works, and if the discrete time is according to a rational frequency you would get infinities with large enough times.
With discrete times over a finite interval (such as you have), there very well might not be any locations where w(t) is infinite... it might well be all zero.

1 Commento

Hi Walter,
I'm not following this statement:
"But you are not doing integration, you are doing summation. And when you do summation, the function C*dirac(X) is infinity * sin(C ) if X is exactly equal to 0 in the summation and is otherwise 0."
In the context of this statement, integration is referring to integration over the independent variable of the signal, but the summation in the Question is not over the independent variable, so I'm not sure why summation is being contrasted against integration. Regardless, where does infinity*sin(C) come from?

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by