** Matlab probability generating function**

function root = modsecant(func,del,xr,acc,K,P,R)

%Firstly we evaluate the function at the first guess of the root and at

%a small pertubation, del, from the the first guess of the root.

fxr=feval(func,K,P,R,xr);

% xr at the pertubation is referred to as xrd

xrd=xr+del;

fxrdel=feval(func,K,P,R,xrd);

%Now we can evaluate a numerical estimate of the derivative

dfxr=(fxrdel-fxr)/del;

% We will use a 'While' loop to loop through our guesses at the root of the

% function. Whilst the value of the function evaluated at the root is

% greater than the accuracy we have specified, 'acc' then we keep looping.

% We are also going to count the number of loops it takes to find the root

% in the variable, 'LoopNum'

i=0;

while (abs(fxr)>acc)

%Evaluate the new guess at the root using the Newton-Raphson formula

xr=xr-fxr/dfxr;

%The values of the function at the new guess and at a small pertubation

%from the new guess can then be evaluated

fxr=feval(func,K,P,R,xr);

xrd=xr+del;

fxrdel=feval(func,K,P,R,xrd);

%Now we can evaluate a numerical estimate of the derivative

dfxr=(fxrdel-fxr)/del;

% After each attempt we increment our number of guesses at the root by one.

% Note: This has no effect at all on the routine. It is just so we can

% plot the guesses it takes before we arrive at the solution.

**matlab price bonds with default risk mfile**

i=i+1;

LoopNum(i)=i;

Storage_xr(i)=xr;

Storage_fxr(i)=fxr;

end

subplot(1,2,1)

plot(LoopNum,Storage_xr)

xlabel('Iteration number')

ylabel('Guess at the root, t(m)')

subplot(1,2,2)

plot(LoopNum,Storage_fxr)

xlabel('Iteration number')

ylabel('Value of function at current guess of the root')

root=xr;

MATLAB Assignment help | Programming Assignment help | Online Tutoring

Assignment Writing Help

- Science Assignment Help
- Math Assignment Help
- Chemistry Assignment Help
- Physics Assignment Help
- Biology Assignment Help
- Psychology Assignment Help
- History Assignment Help
- Geography Assignment Help
- English Assignment Help
- Humanities Assignment Help
- Nursing Assignment Help
- Social Science Assignment Help
- Arts and Architecture Help
- Statistics Assignment Help
- Law Assignment Help
- Computational Mathematics Assignment Help

Engineering Assignment Services

- Programming Assignment Help
- Database Help
- Data Structure Assignment Help
- Operating Systems Assignment Help
- Computer Network Assignment Help
- UML Diagram Assignment Help
- IT Assignment Help
- Game Programming Help
- Computer Science Assignment Help
- Information Systems Assignment Help
- Chemical Engineering Assignment Help
- Civil Engineering Assignment Help
- Electrical, Electronics Help
- Mechanical Engineering Assignment Help
- Petroleum Engineering Assignment Help
- Biochemical and Biotechnology Help

Do My Assignment Help

- Accounting Assignment Help
- Finance Assignment Help
- Economics Assignment Help
- Marketing Assignment Help
- Human Resources Assignment Help
- Operations Management Assignment Help
- Strategy and Planning Help
- Project Management Help
- Case Studies Writing Help
- Political science
- Referencing Help
- Assignment Help Websites
- Online Assignment Help
- Do My Assignment
- Do My Homework

Write My Essay Services

- Essay Writing Help
- Business Essay Writing Help
- Assignment Writing Services
- Plagiarism Free Essay Writing
- Essay Editing Service
- Dissertation Writing Services
- Custom Writing Help
- Write My Essay
- Thesis Writing Help
- Write My Paper
- Paper Writing Service
- Academic help
- College Essay Writing
- Cheap Essay Writing