Solving a function with fsolve
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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!!!
0 Kommentare
Antworten (1)
Stephan
am 24 Okt. 2020
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 Kommentare
Stephan
am 24 Okt. 2020
Bearbeitet: Stephan
am 24 Okt. 2020
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.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!