필터 지우기
필터 지우기

Programme not running when using fsolver.

조회 수: 2 (최근 30일)
Honey Adams
Honey Adams 2018년 8월 6일
댓글: Honey Adams 2018년 8월 8일
I would be glad if anyone could help me identify the reason my code isn't running when using fsolve.
  댓글 수: 4
Honey Adams
Honey Adams 2018년 8월 7일
I posted it there since the conversation here got stuck.
Honey Adams
Honey Adams 2018년 8월 7일
Doy you mind helping me out ?Thank you

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

채택된 답변

Walter Roberson
Walter Roberson 2018년 8월 6일
Your V and Z is 10 x 6 and your r and s is 6 x 1 and your k is 10 x 1. These all go together in a way such that for
f(1)=(1/(1+b^2 +g^2)*((V'*V)^-1 * V'*((center-(W*r + Z*s))+ (left-(W*r +Z*s)*...
b - k*d)*b + (right-(W*r+Z*s)*g - k*h)*g)))-a;
the right hand side is 6 x 1. A 6 x 1 vector cannot be stored in a single numeric location such as f(1)
The f(2) and f(3) entries have the same size difficulty.
You have
f(4)= ((a'*V' + r' * W' + s'*Z')*(V*a + W*r + Z*s)^-1 *(left'*(V*a +W*r + Z*s)...
-(a'*V' + r'*W' +s'*Z')*k*d))- b;
The ^-1 has priority over matrix multiplication, so the (V*a + W*r + Z*s) is computed and attempted to be raised to -1. But (V*a + W*r + Z*s) is 10 x 1 and you can only raise a non-scalar with ^-1 if you are working with a square matrix.
f(5) has the same problems as f(4).
f(6) and f(7) are okay: they each compute scalars.
Your ^-1 of matrices are matrix inverse requests, just as if you had coded inv() . However, you should avoid coding ^-1 or inv() calls as that operation is not numerically stable. You should be changing to using the / or \ operators. For example,
(V'*V)^-1 * V'*ETC
should be re-coded as
(V'*V) \ V'
  댓글 수: 26
Walter Roberson
Walter Roberson 2018년 8월 7일
My tests suggest that there might be a solution near
[3.0764454923181308, -0.29750955941213153, 1.32522678326379184, -5.67281188388481006, 3.71962594859759532, 1.79157413120165088, 0.0913355342239042522, -3.3450226246250705, 2.5660435058715354, 0.0354122586159170138, -0.177027435264798, -1.15044309568988101, 1.65430815977474821, -1.10152163665358227, 0.626930903877788825, -0.316658524647466799, -0.740546143279594782, 0.803505679158440511, -44.5712374138825425, 2.09613318816875438, 149.797294636857373, -6.26552007745399386]
Because of the 22 dimensional nature of the problem, searching is expensive.
Honey Adams
Honey Adams 2018년 8월 8일
oh kk. Thank you very much, Walter and Alan.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by