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

Andrew Newell
Andrew Newell 2015년 2월 4일
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

댓글을 달려면 로그인하십시오.

 채택된 답변

Roger Stafford
Roger Stafford 2015년 2월 5일

1 개 추천

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

Maharjan
Maharjan 2015년 2월 5일
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.
Wasim Abbas
Wasim Abbas 2020년 9월 26일
could you please send me your code. I need this in my research

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2015년 2월 4일

댓글:

2020년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by