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)

 采纳的回答

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.

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Test Execution 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by