Solving a function with fsolve

8 ビュー (過去 30 日間)
Andreas S
Andreas S 2020 年 10 月 23 日
編集済み: Stephan 2020 年 10 月 24 日
Hello everyone! As im new in matlab i would like your help to solve an issue that i have with fsolve .
I have created a function in a new matlab file and i named the matlab file as the name of the function. I named it NEcdf.
function fx = NEcdf(x,hetta_RL,omega_RL,delta_RL,alpha_VaR)
alpha_VaR=0.99;
hetta_RL=-0.0047;
omega_RL=0.0077;
delta_RL=0.0041;
fx = ((cdf('Normal',(x-hetta_RL)./omega_RL))-((exp(omega_RL^2)./2.*(delta_RL).^2 - (x-hetta_RL)./delta_RL)).*(cdf('Normal',(x-hetta_RL)./omega_RL - omega_RL./delta_RL))-alpha_VaR);
end
Then i have the following codes:
alpha_VaR=0.99;
hetta_RL=-0.0047;
omega_RL=0.0077;
delta_RL=0.0041;
f=fsolve(@(x) NEcdf(hetta_RL,omega_RL,delta_RL,alpha_VaR)
VaR_NE=fsolve(f,0)
And i dont get the result i expect from this solver.
Thank you in advance!!!

回答 (1 件)

Stephan
Stephan 2020 年 10 月 24 日
VaR_NE = fsolve(@NEcdf,0)
function fx = NEcdf(x)
alpha_VaR=0.99;
hetta_RL=-0.0047;
omega_RL=0.0077;
delta_RL=0.0041;
fx = ((cdf('Normal',(x-hetta_RL)./omega_RL))-((exp(omega_RL^2)./2.*(delta_RL).^2-...
(x-hetta_RL)./delta_RL)).*(cdf('Normal',(x-hetta_RL)./omega_RL-...
omega_RL./delta_RL))-alpha_VaR);
end
  2 件のコメント
Andreas S
Andreas S 2020 年 10 月 24 日
I'm running your suggested VaR_NE and the problem still remains. When I run the VaR_NE the result is the number I use at fsolve brackets. For example when I use zero at fsolve it gives me zero as e result. When I use 1 the result is zero again. When I use number two or bigger, the result I get is hetta_RL. What's is the problem?
Stephan
Stephan 2020 年 10 月 24 日
編集済み: Stephan 2020 年 10 月 24 日
I guess it could be a problem how you use the cdf function. Calling this function with two arguments is used when you have a distribution object as input parameter. But you only have numbers. So my guess is, that you have to give at least 3 input parameters to the cdf function. The first one is 'normal', the second should be the input vector for that you want to calculate, number 3 (and maybe 4) are mu (and sigma) of your normal distribution. The fact that you don't do this, let's me guess this could be the problem.

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

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by