Matlab: create a function that will use the secant method

Assignment Help MATLAB Programming
Reference no: EM13160139

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

 

 

Reference no: EM13160139

Questions Cloud

What is the opportunity cost of producing more units : If a country is currently producing 11 units of health care and 16 units of education, what is the opportunity cost of producing 5 more units of education?
State what occurs at the molecular level of an extraction : What occurs at the molecular level of an extraction? We did an extraction of benzoic acid using NaOH and diethyl ether dried to 1, 4-dimethoxybenzoate using NaOh
Factory overhead applied to production : During the period, labor costs incurred on account amounted to $250,000 including $200,000 for production orders and $50,000 for general factory use. In addition, factory overhead applied to production was $23,000. From the following, select the e..
What is the ph : A volume of 25.0 mL of 0.100 M HCO2H(aq) is titrated with 0.100 M NaOH(aq). What is the pH after the addition of 12.5 mL of NaOH? (Ka for HCO2H = 1.8 × 10-4)
Matlab: create a function that will use the secant method : MATLAB: Create a function that will use the Secant method
Which would be most abundant : Niremberg used the enzyme polynucleotide phosphorylase to assembleRNAs with random sequences in the absence of a template. Supposethey added the enzyme to a solution of 90%CTP and 10%UTP, and thenused a cell-free system of protein synthesis to mak..
C program that compare the time required : Write a C program that compare the time required to compute the product of two 10,000 x 10,000 matrices with and without optimization for locality.
Gain on the sale of investments : On the statement of cash flows prepared by the indirect method, a $50,000 gain on the sale of investments would be:
What other changes might you want to make at the same time : Why would a tax credit for mortgage intrest be worth more to lower income families than a deduction? Would you favor changing the benefit from a tac deduction to a tax credit? What other changes might you want to make at the same time? WHY?

Reviews

Write a Review

 

MATLAB Programming Questions & Answers

  Write a user defined function

Write a user defined function FindFrequency which inputs are a time and a wave elevation vector and output the approximated wave frequency (fappr=FindFrequency(t,eta)).

  Compute the eigenvalues and eigenvectors of the matrix

Compute the eigenvalues and eigenvectors of the matrix

  Boundary conditions for the finite element model

The computer program or the finite element model for one value of a and the excel file for finite element results processing;Boundary conditions for the finite element model

  Determine the inputs, outputs, relevant formulas

determine the inputs, outputs, relevant formulas

  Create functions in file

Create Functions in File and how to code this function - Declare function inputs, and outputs

  Fourier transform and biosignal analysis

Fourier Transform and Biosignal Analysis - series data into its frequency components for the purpose of signal analysis and processing.

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Fingerprint watermarking techniques

Need to investigate the best method to embed watermark image into fingerprint image.

  Determine the size for variables used in matlab program

If b=3, a=6 how many loops would the given program do? what will be the out put for z(4)? what would be size (in rows and columns) for variables z, i and b?

  Write a script to solve the following systems of equations

Write a script to solve the following systems of equations using both matrix left division (\) and the inverse matrix method and Show that you have tested your MATLAB code appropriately

  Import the data into matlab and name the array ace_data

Parameter is related to the energy of the storm, since kinetic energy is proportional to velocity squared. However, it does not take into account the size of the storm, which would be necessary for a true total energy estimate.

  Implement linear support vector machine to classify data

code to implement linear Support vector machine to classify data (without using matlab built in function).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd