Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

MATLAB: Create a function that will use the Secant method to try to find a root by modifying the False Position method function written bellow. Because this method may diverge, you should limit the number of time the loop repeats.

function [fproot,zeroerror] = falsepos(func, low, high, accepterror)
% function to find the root of an equation using false position method and
% two guesses.
% input: function, low value for a guess, high value for a guess, and
% acceptable error for root.
% output: The root or an empty matrixif the root is not found.
% processing: Find a possibility for the root by creating a line between
% low value high value. New possibility is where the line
% intersects the x-axis. New possibility may be calculated by
% the equation
% xnew = xhigh - ((f(xhigh)(xlow -xhigh))/(f(xlow) - f(xhigh))
% Then f(xnew) will be calculated. If f(xnew) is equal to 0,
% set root to xnew and set logical variable to false.
% Otherwise compare the sign of f(xnew) is the same as the
% sign of low. If it the same, then set low to xnew,
% set high to xnew. Repeat until root is found or difference
% between xlow and xhigh is less than 0.0000001.

notfound = true;
diff = abs(high - low);
fproot =[];
while (notfound & diff > 0.00000001 )
flow = func(low);
fhigh = func(high);
xnew = high - ((fhigh)*(low - high))/(flow - fhigh);
fnew = func(xnew);
if abs(fnew) < accepterror
fproot = xnew;
notfound = false;
zeroerror = fnew;
elseif sign(fnew) == sign(flow)
low = xnew;
else
high = xnew;
end
diff = abs(high - low);

end

if notfound
disp('No roots were found in this range!')
disp('Try again with new guesses')
end

 

 

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M9450265

Have any Question?


Related Questions in MATLAB

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

What comparison of means test was used to answer the

What comparison of means test was used to answer the question

Assignmentq1 find the laplace transforms of the following

Assignment Q.1 Find the Laplace transforms of the following functions: (a) t 2 + at + b and (b) sin(2nΠt/T) Q.2 Find f (t) for the following F(s) = α[ f (t)]. (i) 5/(s + 3), (ii) 1/s 2 + 25, (iii) 1/s(s+1) Q.3 Find the L ...

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Lab assignment - matlab matrix relationallogical operators

Lab Assignment - MATLAB Matrix, Relational/Logical Operators and Plotting This laboratory exercise/assignment will involve you 1) practicing multiplication operators in MATLAB; 2) practicing relational and logical operat ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Prepare a 3 - 10 pages long reportprepare a presentation

Prepare a 3 - 10 pages long report Prepare a presentation with 5 - 9 slides. The slides will include introduction (need and similar work), theoretical background (tested neural networks), Data, Results (Comparison of the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As