How can I choose powers of each variable separately and get it's value?

6 ビュー (過去 30 日間)
behzad
behzad 2014 年 5 月 23 日
編集済み: Matt J 2014 年 5 月 23 日
Hi every one I solved a equation leading to function like this f=x^a*y^b*z^c; but I don't know a,b and c.I want matlab to show me these power constants but have trouble making matlab select them. How can I choose powers of each variable separately and get it's value?
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 23 日
Can you explain what how did you get f? is f symbolic class?
behzad
behzad 2014 年 5 月 23 日
編集済み: behzad 2014 年 5 月 23 日
No. It was just an example.I want to do a numerical integration process using guass quadrature using equation ∫_A▒〖B_i ξ_1^(a_i ) 〗 ξ_2^(b_i ) ξ_3^(c_i )=B_i (a_i !b_i !c_i !)/((a+b+c+2)!) but the and I have a long polynomial including lots of these integrals.I want matlab to divide each term seperately term by term and identify the power constants ai,bi,ci in each term so I will be able to exert them into the right side of equation.

サインインしてコメントする。

回答 (2 件)

Matt J
Matt J 2014 年 5 月 23 日
If there is no error in the equations, you can take logs and turn it into a linear equation in a,b, and c
logf=a*logx+b*logy+c*logz
  1 件のコメント
Matt J
Matt J 2014 年 5 月 23 日
編集済み: Matt J 2014 年 5 月 23 日
You can also use the linearization to develop an initial guess for the fminsearch approach (See Star Strider's answer).

サインインしてコメントする。


Star Strider
Star Strider 2014 年 5 月 23 日
You can do a nonlinear fit with fminsearch:
f = @(p,x,y,z) x.^p(1) .* y.^p(2) .* z.^p(3); % Function
x = 3; % Define variables
y = 5;
z = 7;
s = 13; % Define f(x,y,z,) = s
objfcn = @(p) f(p,x,y,z) - s; % Objective function = 0 when f(x,y,z,) = s
[b, fval] = fminsearch(objfcn, [1 1 1])
produces:
b =
11.3000 -3.0500 -25.5000
fval =
-13.0000
  4 件のコメント
Matt J
Matt J 2014 年 5 月 23 日
編集済み: Matt J 2014 年 5 月 23 日
If you don't include the norm(), your error function is signed. fminsearch will then look for the 'p' that makes the error function as negative as possible.
As an example, consider the alternative data x=13,y=1,z=1, s=13. With
objfcn = @(p) f(p,x,y,z) - s;
I obtain the false solution,
b =
-18.8889 6.2222 5.4278
fval =
-13
whereas when the norm() is included, fminsearch correctly detects that the initial point [1 1 1] is a solution,
b =
1 1 1
fval =
0
Star Strider
Star Strider 2014 年 5 月 23 日
Noted. I’ve only done minimisation or least-squares curve fitting with fminsearch, so never encountered that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by