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
Ameer Hamza
2020년 6월 21일
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.
Bharath Anantharamaiah
2020년 6월 21일
Ameer Hamza
2020년 6월 21일
Can you share their values?
Bharath Anantharamaiah
2020년 6월 21일
David Goodmanson
2020년 6월 21일
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?
Bharath Anantharamaiah
2020년 6월 22일
편집: Bharath Anantharamaiah
2020년 6월 22일
David Goodmanson
2020년 6월 22일
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?
Bharath Anantharamaiah
2020년 6월 22일
David Goodmanson
2020년 6월 22일
편집: David Goodmanson
2020년 6월 22일
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.
Bharath Anantharamaiah
2020년 7월 4일
Bharath Anantharamaiah
2020년 7월 14일
David Goodmanson
2020년 7월 15일
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
2020년 6월 21일
편집: KALYAN ACHARJYA
2020년 6월 21일
0 개 추천
Please try any issue let me know
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
Bharath Anantharamaiah
2020년 7월 5일
David Goodmanson
2020년 7월 6일
편집: David Goodmanson
2020년 7월 6일
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!