Calculating the contributing terms of a summation equation

I am trying to calculate the value of a variable in a summation term. Could any of you share some leads about the coding technique in Matlab? My equation looks like:
,
in which I know the values of Y, and z. I am looking for an idea and methodology to calculate the values of the variable .

댓글 수: 12

Are Y and yi scalars? If yes, then your equation will have infinite solutions. You need to add more constraints to find a unique solution.
Dear Ameer,
Thank you for the reply. Fortunately Y and yi are vectors.
Can you share their values?
Of course,
Yi:
24.2287099411759
26.3143683291633
27.4085397420593
28.2054843510947
28.8468469654772
29.3899452604636
29.8644047981385
30.2877674971400
and yi:
0.00530516476972985
0.000944139492918023
0.000518178884485241
0.000357078397962586
0.000272392323140163
0.000220174822459144
0.000184756982030393
0.000159154943091895
z:
188.495559215388
1059.16552321027
1929.83548720516
2800.50545120004
3671.17541519493
4541.84537918982
5412.51534318470
6283.18530717959
Pay attention that z has no index!
Hi Bharath,
You seem to be saying that the sum is not sum(xi*yi*zi). Rather sum(xi*yi) = S, a scalar, and the the resulting equation is Y = S*z, is that correct?
Hi David,
Yes that is correct. Let me simplify it more. Let us assume N=3. Picking the values for the terms from the previous comment,
24.2287099411759 = (x1 * 0.00530516476972985 + x2 * 0.000944139492918023 + x3 * 0.000518178884485241) * 188.495559215388
.
.
.
I hope this will give some clarity.
there are eight rows in each of Y and z. Does the x vector stay the same for a best fit for all rows taken together, or does the x vector change for each row of Y and corresponding row of z?
The x vector remains the same for all the rows of Y and z. And the dimensions of Y and z is would be automatically adopted to Nx1. My bad, I was not clear about this in my previous comment.
If x=(x1, x2, x3), y=(y1, y2, y3), Y and z will automatically be of the dimension 3x1. Please feel free to ask if you have more questions.
Hi Bharath,
ok, now for the data. Whatever x turns out to be, then wth sum(xi*yi) = S, the resulting equation is Y = S*z. Since the nature of the fit is simply multiplicaton of z by a constant, for visual comparison purposes one can leave z alone and multiply Y by a constant. So let Y equal z at, say, the fifth point in the array:
nvec = 1:length(z)
figure(1)
plot(nvec,z,nvec,(Y/Y(5))*z(5))
grid on
The plot shows that Y and z do not resemble each other at all. Multiplying Y by a constant is the only fitting option, so any fit is going to be terrible. So there is that to consider before even getting into the details of x.
Hi David,
Apologies for late reply. I see your point. Let me share the exact equation that I need to calculate. So it will alleviate the issue. Here it is:
.
In this equation, I know the values of the vector Q, y and . I need to calculate the value of the vector . I believe I need to use some optimisation algorithms.
Hi David,
Vectors Q(y) and y are having same dimensions. However, the dimension of q_i and x_i is solely dependant on the value of N. There is no neccessity that the dimension of Q(y) and q_i be the same. And most certainly N>2.
The idea is simple. I have a curve that is defined by Q(y) vs y. Now I need to calculate the values of pairs of q_i and x_i for fitting this curve! Hope I am clear now?
.
HI Bharath,
I am aware that Q (used to be called Y) and y have the same length, and that q and x have the same length, which may well be diffferent than the length of Q&y. Given the equatiion you posted on July 4, I believe the answer I posted is apt.

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

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 6월 21일
편집: KALYAN ACHARJYA 2020년 6월 21일

0 개 추천

댓글 수: 1

Dear Kalyan,
Thank you for the reply. In the link you shared, the value of dependent term is calculated based on the values of independent terms. My case is the opposite. In the equation
,
I already have the value for the dependent term (Y) and I need to calculate the possible values of the independent term () using iterations.

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

David Goodmanson
David Goodmanson 2020년 7월 5일
편집: David Goodmanson 2020년 7월 5일
Hi Bharath,
suppose the sum involving q is done over a dummy index j instead of i. It appears that Y and y are vectors of the same length so the expression is
Yi = sum{j=1,N} qj*xj*yi/(1+xj^2*yi^2)
or in matrix notation
Y = M*q where M(i,j) = xj*yi/(1+xj^2*yi^2)
You don't say how the length of Y and y compare to N, but if that length is >= N, then a least squares solution for q is just
q = M\Y.

댓글 수: 2

Hi David,
The approach you propose is absolutely perfect if the value of N is 1. However, if I have to choose N>1, I believe the calculation does not hold good. Please give me sometime, I am exploring the case that you described, i.e. if vector lengths of Q and q is not same as N. I will clear that doubt as soon as possible.
I will assume here that vectors Y and y have the same length as each other (if not then I don't understand the equation at all). But assuming Y and y are the same length, the key is that the entire expression is linear in q, so that a minimal q can be determined with standard linear algebra.
Assume that Y and y have length A. Then as I mentioned before, this can be put into matrix multiplication form,
Y = M*q
where Y is Ax1, q is Nx1 and M is AxN. This expression has A equations and N unknowns which are the elements of q.
If A=N there is an exact solution for q (assuming that matix M is nonsingular, which seems likely). If A>N there are more equations than unknowns and q = M\Y solves for q in the least squares sense. If A< N there are more unknowns than equations and q is not determined completely but can vary somewhat.

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

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2020년 6월 21일

댓글:

2020년 7월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by