Summation with a vector

1 view (last 30 days)
Brent
Brent on 11 Nov 2013
Commented: Azzi Abdelmalek on 11 Nov 2013
Hi guys I'm new here and I'm just learning Matlab for signal processing.
I'm trying to solve this summation:
I've tried using sum:
>> n=[-10:10];
>> x=zeros(1,length(n));
>> sum(x(n==i),i=1..10);
but I'm getting a not a valid target assignment error..
I also saw symsum but I don't know how to implement that on computing a vector.
Please help me, and thanks in advance. P.S. I'm using MATLAB 7.12.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 11 Nov 2013
Edited: Azzi Abdelmalek on 11 Nov 2013
n=-10:10
x=[zeros(1,11) ones(1,10)]
stem(n,x)
  2 Comments
Brent
Brent on 11 Nov 2013
I'm sorry but can you explain 2nd line of the code? I don't get how you did the summation from that. And to make sure, is the output zeros from -10:0 and ones from 1:10?
Azzi Abdelmalek
Azzi Abdelmalek on 11 Nov 2013
By definition, Kronecker delta function is defined as:
delta(k)=1 if k=0
delta(k)=0 elsewhere
you have the sum of delayed Kronecker delta function,
delta(k-1)=1 if k=1
delta(k-1)=0 elsewhere
delta(k-2)=1 if k=2
delta(k-2)=0 elsewhere
...
delta(k-10)=1 if k=10
delta(k-10)=0 elsewhere
Make the sum of these delayed signals, you will find what I posted above

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!