フィルターのクリア

How to find numerical roots for multivariable functions

1 回表示 (過去 30 日間)
muly san
muly san 2014 年 4 月 23 日
コメント済み: Star Strider 2014 年 4 月 23 日
Hi, I want to draw some graphs for my work. This is my function:
function H_star=RHS1(H,h,theta,A);
a=A.*((1.-H)./H).^(1-theta);
if (1/a)*(1-1/a)>h;
H_RHS=1/(2*a)-h^2*a^3/(2*(a-1)^2);
else
H_RHS=0;
end
H_star=H_RHS-H;
end
I want to find a root for this function (as function of H). I tried to do it by this command (I set examples values for the parameters):
fzero (inline('RHS1(H,0.1,0.6,1.1)'),0.5)
By this way I succeed to get an answer.
My question is how I can draw this fixed point as function of one of the parameters. For example, I want to plot the fixed point as function of A. I tried to do it in this way:
j=1;
for A=0.5:0.01:2;
H_star(j)=fzero (inline('RHS1(H,0.1,0.6,A)'),0.5)
j=j+1;
end
But I get the message "Not enough inputs to inline function."
In adition, I want to get numeric derivatives of this fixed point according to the parameters.
Thanks!

回答 (1 件)

Star Strider
Star Strider 2014 年 4 月 23 日
編集済み: Star Strider 2014 年 4 月 23 日
I suggest this as a possible solution:
  • Define h and theta in your workspace,
  • Define A = 0.5:0.01:2; in your workspace,
  • Create a for (or while) loop for j,
  • Replace ‘for A=...’ with for k = 1:length(A)
  • Create the anonymous function (instead of using the inline function) in the loop after the for k = 1:length(A) statement and then call fzero with it:
f = @(H) @RHS1(H,h,theta,A(k));
H_star(i,k) = fzero(f, 0.5);
This should get you started.
NOTE: I did not run your code, so my suggestions are untested but should work. Also, it is best not to use i and j as index counters, because MATLAB uses them for its imaginary operators.
  2 件のコメント
muly san
muly san 2014 年 4 月 23 日
Thank you very much! I will try it..
Star Strider
Star Strider 2014 年 4 月 23 日
My pleasure!

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

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by