Summation with resultant vector's index as upper limit

6 views (last 30 days)
Hello,
I'm trying to write this summation in Matlab
I couldn't find any example of this anywhere, maybe someone can help me with the syntax here.

Accepted Answer

Torsten
Torsten on 13 Dec 2018
https://de.mathworks.com/help/matlab/ref/conv.html#bucr92l-2
  8 Comments
Kristoffer Lindvall
Kristoffer Lindvall on 13 Dec 2018
Edited: Kristoffer Lindvall on 13 Dec 2018
Yeah, I tried that but I got a different result.
The full conv gives c_full = [0.5 2 2], and same conv gives c_same=[2 2]. The answer I need is c = [0.5 2]. Atleast for the first sum in the formula.
a = (1:2);
b = (1:2);
c1 = conv(a,b)/2;
c2 = conv(a,b'same')/2;
This is the best I could do for the entire formula
n = length(a);
c = zeros(1,n);
for k=1:n
c(k) = sum(a(1:k).*b(k:-1:1)/2)+sum(a(2:n-k).*b(2+k:n-k)/2)+sum(a(2+k:n-k).*b(2:n-k)/2);
end
Bruno Luong
Bruno Luong on 13 Dec 2018
How hard to extract k+1 first elements of conv full result?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!