Hello! I need some help regarding a project

How can I write a combination between a sum and a dirac? I have the following function:

symsum(((-1)^k)*dirac(t-k*25), k, -Inf, Inf)

function [ rez ] = test2( t ) rez = symsum(((-1)^k)*dirac(t-k*25), k, -Inf, Inf) end

>> test = 0:25

test =

Columns 1 through 22
     0     1     2     3     4     5     6     7     8     9    10    11    12    13    14    15    16    17    18    19    20    21
Columns 23 through 26
    22    23    24    25

>> test2(test) Undefined function or variable 'k'.

Error in test2 (line 2) rez = symsum(((-1)^k)*dirac(t-k*25), k, -Inf, Inf)

 Accepted Answer

You have to declare ‘k’ and ‘t’ in your syms statement:
syms k t
S(t) = symsum(((-1)^k)*dirac(t-k*25), k, -Inf, Inf);
test = sym(0:25);
rez = vpa(S(test))
I leave the rest to you.

2 Comments

Thank you for your help!
As always, my pleasure!

Sign in to comment.

More Answers (0)

Asked:

on 24 Dec 2017

Commented:

on 26 Dec 2017

Community Treasure Hunt

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

Start Hunting!