a sequence of a sum of product

I have a sequence H and a function (erfc).
I want to find a sequence of a sum of product such that
H=[1 2 3 4 5 6 7 8 9 0]
for p =(1:10)
h(p) = H(m)*erfc(p-m+1) where m goes from 1 to p
that means
h(1) = H(1)* erfc(1)
h(2) = H(1)*erfc(2)+ H(2)* erfc (1)
h(3) = H(1)*erfc(3) + H(2)*erfc(2)+H(3)*erfc(1)
h(4) = H(1)*erfc(4)+H(2)*erfc(3)+H(3)*erfc(2)+H(4)*erfc(1)
and so on
My biggest hurdle is to indexing sequence H so that I can multiply with the function. I am getting error related to sym/subsindexing.
Any help is greatly appreciated.
Thank you Maharjan

2 Comments

Can you show us the code you have so far?
Thanks Andrew for you interest. So far, I got
syms m p
for i=(1:1:N) % N is length of a sequence
k=(p-m+1);
q= erfc(k);
h=symsum(q,m,1,p);
f=symfun(h,p);
a(i)=f(i);
b(i)=eval(a(i));
end
This gives me exactly what I wanted to get before multiplying by H (listed above). Theoretically, I just need to multiply q by H ("q*H(m)") and replace q by the new term in "h". But I could not structured my codes so that Matlab knows what I wanted to do. I get an error related to a subsindex.
Thank you

Sign in to comment.

 Accepted Answer

You can vectorize your summation. I assume H is a 10-element row vector as you have shown it.
h = zeros(10,1);
for p = 1:10
h(p) = H(1:p)*erfc((p:-1:1)');
end
Note: You could also use matlab's 'conv' (convolution) function.

2 Comments

I did not realize that i was doing convolution until you mentioned. Thanks for your help. I truly needed the break through. I was convoluted with in symbolic math.
could you please send me your code. I need this in my research

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!