Sign in

username:

password:



Not a member?

Search matlab



Search tips

Subscribe to matlab



matlab by Keywords

Atanh | Autocorrelation | Bandpass Filter | C++ | Conv | Database | Deconv | Excel | FFT | Filter | Filtering | FIR | Fourier Transfrom | FSK | Gaussian Noise | Haykin | IFFT | Image | Java | LFSR | LMS | LPC | MEX | OFDM | QPSK | Radix | Random | Sampling | Segmentation | Simulink | Visual Basic | Waveform | Wavelet

Ads

Discussion Groups

Discussion Groups | Matlab DSP | a small problem about "fsolve"

Technical discussion about Matlab and issues related to Digital Signal Processing.

  

Post a new Thread

a small problem about "fsolve" - lost_the_loving_feeling - May 17 8:34:00 2008



Hallo all, 

first I would like to thank you again for helping me solve the "NaN"
problem last time. Now I have a small problem with "fsolve" in
optimization toolbox. 

I wrote a function with 7 variables and two equations. I can give
concrete numbers to 5 of the variables in advance so that with two
equations the rest two variables can be solved by "fsolve". The
problem is, according to the codes I wrote (see below), whenever the
value of the five variables change, I need to open this function and
revise those values so that the rest two variables can be recalculated
by "fsolve" based on the new value of other five variables. Is it
possbile that I could define the five variables just in the codes
(outside of the function) before applying fsolve? 

Thank you very much!
(Below are the codes of the function. It's basically a Merton model to
calculate the asset value and asset volatility given the value of
other 5 variables. The first 5 variables are those I would like to
define outside of the function, the last two are those I want "fsolve"
to calculate. d_1 and d_2 are just defined by those 7 variables)

function funk = merton_test(X)

equity = 275.08; % equity value of a company
r_f = 0.04253; % risk free rate of return
T = 1; % the period before maturity of debt, here one year
debt = 101.34; % debt of the company
sigma = 0.42979; % standard deviation of the equity

asset = X(1); % asset value
asset_vol = X(2); % volatility of the asset

d_1 = (log(asset / debt) + (r_f + asset_vol ^2 / 2) * T) / (asset_vol
* sqrt (T));

d_2 = (log(asset / debt) + (r_f - asset_vol ^2 / 2) * T) / (asset_vol
* sqrt (T));
funk (1) = equity - asset * norm_cdf(d_1) + exp(-r_f * T) * debt *
norm_cdf(d_2); 

funk (2) = asset_vol - equity / (asset * norm_cdf(d_1)) * sigma;



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )