Solving a system of equation with two different series.

조회 수: 1 (최근 30일)
Shaibal Ahmed
Shaibal Ahmed 2016년 8월 12일
댓글: Torsten 2016년 8월 15일
Hi, could someone help me writing the following equation? The two different series (j & i) is confusing me.
  댓글 수: 7
Shaibal Ahmed
Shaibal Ahmed 2016년 8월 12일
편집: Shaibal Ahmed 2016년 8월 12일
a1 & a2 were calculated to make the equation simpler, they are fixed value and i is the index, the sum of all h's (36 of them) should be equal to 1.
John D'Errico
John D'Errico 2016년 8월 12일
편집: John D'Errico 2016년 8월 12일
When did you tell s about the sum constraint on h? lol. If you tell us everything in the beginning, it would help.
Without that constraint on h, this is a simple loop. With it, we have a set of 36 LINEAR equations in 35 unknowns, since h(1) is known. As such, there will generally be no exact solution.

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

답변 (2개)

Torsten
Torsten 2016년 8월 12일
beta=...;
a1=...;
a2=...;
h(1) = 0.026;
for i=2:36
h(i)=1-sum(h(1:i-1))-(beta*exp(-a1*i)*(a1*i+1)+(1-beta)*exp(-a2*i)*(a2*i+1);
end
Best wishes
Torsten.

John D'Errico
John D'Errico 2016년 8월 12일
편집: John D'Errico 2016년 8월 12일
Given your comments, assuming that a1 and a2 are not problematic, this is a simple loop. Not sure what the issue is. Start at the beginning.
h = zeros(1,36);
h(1) = 0.026.
for i = 2:36
h(i) = 1 - sum(h(1:(i-1)) - (beta*exp(-a1*i)*(a1*i+1) + (1-beta)*exp(-a2*i)*(a2*i+1)));
end
Note that I preallocated the vector h. Growing a vector over time is a slow operation, that will get slower as your vector gets larger. So preallocate vectors when they will be grown.
Edit: given the extra information about the sum of the h vector to be 1...
Without that constraint on h, this is a simple loop. With it, we have a set of 36 LINEAR equations in 35 unknowns, since h(1) is known. As such, there will generally be no exact solution.
So you need to explain what you really need to do. Tell us what we need to know, or else we are just chasing a moving target.
  댓글 수: 4
Shaibal Ahmed
Shaibal Ahmed 2016년 8월 13일
편집: Shaibal Ahmed 2016년 8월 14일
Hi, this is how I did it.
beta=...;
a_1=...;
a_2=...;
x = zeros (1,36)';
for i = 1:36
x(i) = beta * (exp (-a_1 * i)) * ( a_1 * i + 1 );
end
y = zeros (1,36)';
for i = 1:36
y(i) = (1 - beta) * (exp (-a_2 * i)) * ( a_2 * i + 1 );
end
z = zeros (1,36);
for i = 1:36
z(i) = (x(i) + y(i));
end
h = [0.026 -diff(z)]';
s = sum(h);
Torsten
Torsten 2016년 8월 15일
This is not what your formula says.
Also, the sum s of the h_i's from i=1 to i=35 is not 1, but
s=35*h(1)+(z(1)-z(36))
Best wishes
Torsten.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by