Preview

Pdf Foile

Satisfactory Essays
Open Document
Open Document
2228 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Pdf Foile
MATLAB Programs
1. Chapter No. Two

Program 2.1
MATLAB m-file for the Bisection Method function sol=bisect(fn,a,b,tol) f a = f eval(f n, a); f b = f eval(f n, b); if f a∗f b > 0; fprintf(’Endpoints have same sign’) return end while abs (b − a) > tol c = (a + b)/2; f c = f eval(f n, c); if f a ∗ f c < 0; b = c; else a = c; end end; sol=(a + b)/2;

Program 2.2
MATLAB m-file for the Fixed-Point Method function sol=fixpt(fn,x0,tol) old= x0+1; while abs(x0-old) > tol; old=x0; x0 = f eval(f n, old); end; sol=x0;

Program 2.3
MATLAB m-file for the Newton’s Method function sol=newton(fn,dfn,x0,tol) old = x0+1; while abs (x0 − old) > tol; old = x0; x0 = old − f eval(f n, old)/f eval(df n, old); end; sol=x0;

Program 2.4
MATLAB m-file for the Secant Method function sol=secant(fn,a,b,tol) x0 = a; x1 = b; f a = f eval(f n, x0); f b = f eval(f n, x1); while abs(x1-old)> tol new = x1 − f b ∗ (x1 − x0)/(f b − f a); x0 = x1; f a = f b; x1 == new; f b = f eval(f n, new); end; sol=new;

1

Program 2.5
MATLAB m-file for first Modified Newton’s Method function sol=mnewton1(fn1,dfn1,x0,m,tol) old = x0+1; while abs (x0 − old) > tol; old = x0; fa=feval(fn,old); fb=feval(dfn,old); x0 = old − (m ∗ f a)/f b; end; sol=x0;

Program 2.6
MATLAB m-file for second Modified Newton’s Method function sol=mnewton2(fn1,dfn1,ddfn1,x0,tol) old = x0+1; while abs (x0 − old) > tol; old = x0; fa=feval(fn,old); fb=feval(dfn,old); fc=feval(ddfn,old); x0 = old − (f a ∗ f b)/((f b). ˆ 2 - (f a ∗ f c)); end; sol=x0;

Program 2.7
MATLAB m-file for Newton’s Method for a Nonlinear System function sol=newton2(fn2,dfn2,x0,tol) old=x0+1; while max(abs(x0-old))>tol; old=x0; f = f eval(f n2, old); f 1 = f (1); f 2 = f (2); J=feval(dfn2,old); f 1x = J(1, 1); f 1y = J(1, 2); f 2x = J(2, 1); f 2y = J(2, 2); D = f 1x ∗ f 2y − f 1y ∗ f 2x; h = (f 2 ∗ f 1y − f 1 ∗ f 2y)/D; k = (f 1 ∗ f 2x − f 2 ∗ f 1x)/D; x0 = old + [h, k]; end; sol=x0; 2. Chapter No. Three

Program 3.1
MATLAB m-file for finding inverse of a

You May Also Find These Documents Helpful

  • Powerful Essays

    Pt1420 Unit 7 Homework

    • 2430 Words
    • 10 Pages

    From my graph above, I can see that the root of this equation is between x =1 and x = 1.5. The table of x values and f(x) values is shown below. I can work out the f(x) values by substituting the x-values into the equation.…

    • 2430 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    Step 3: Complete the following pseudocode based on the algorithm and the variables you declared above.…

    • 777 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Mr james cox

    • 1220 Words
    • 5 Pages

    Starting at the point ð1, 3Þ, use a step-by-step method with a step length of 0.1 to…

    • 1220 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    C3 Coursework

    • 2611 Words
    • 11 Pages

    In this coursework I am going to investigate numerical methods of solving equations. The methods I will use are:…

    • 2611 Words
    • 11 Pages
    Good Essays
  • Good Essays

    Carry all calculations to six decimals on each intermediate step, then round the final answer to the nearest cent.…

    • 441 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    xs (t). fs = 2Hz , repeat 4. fs = 0.5Hz , repeat 4. fs = 1.5Hz , repeat 4. fs = 2/3Hz , repeat 4.…

    • 333 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Differential Equ

    • 5855 Words
    • 24 Pages

    Differential Problems in MATLAB 1. What Equations Can MATLAB Handle? 2. Where Can I Find Tutorials or Additional Information? Frequently Asked Questions 3. What Changes in Syntax Exist for ODE Solvers? 4. How Do I Reduce the Order of an ODE? 5. How Do I Solve Time-Dependent ODEs? 6. How Do I Use a Fixed Time Step? 7. How Do I Use Stochastic Differential Equations? Examples 8. Systems of Equations 9. Boundary Value Problem (BVP): Channel Flow Stiffness 10. What Is Stiffness? 11. Implicit vs. Explicit Methods 12. Examples Options 13. How Can I Change Options When Solving a Differential Equation? 14. What Option Parameters Can Be Modified? 15. How Can Options Be Used as Functions? Differential-Algebraic Equations and their Index 16. How Can Differential Algebraic Equations Systems Be Solved in MATLAB?…

    • 5855 Words
    • 24 Pages
    Powerful Essays
  • Good Essays

    INTRODUCTION TO MATLAB

    • 832 Words
    • 8 Pages

    1.9 The diameter of a 26 AWG copper (conductivity = σ = 5.69 × 107 S/m) wire is 0.405mm.…

    • 832 Words
    • 8 Pages
    Good Essays
  • Satisfactory Essays

    This will be used to calculate Zj and then Cj-Zj. The BFS will now be checked to see if it’s the absolute extrema for the problem. If not, the process will be repeated in order to find the true extrema values.…

    • 408 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    This chapter covers fundamentals of MATLAB programming. With lots of examples, this chapter offers the essence for beginners to get a handle on programming in MALTAB. Starting from introducing various MATLAB windows and on-line help facilities, the fundamentals of MATLAB programming including data types, statements and matrix representation are explained first followed by matrix manipulations, such as algebraic computation, logical and relationship expressions and data conversion. Then, flow charts in MATLAB programming is illustrated, including loop structures, conditional structures, switches and trial structures. MATLAB function programming and pseudo code processing are covered together with two-dimensional and three-dimensional graphics and visualization techniques. MATLAB graphical user interface (GUI) techniques are explained so that the readers will gain new GUI programming skills to design user-friendly interfaces. Finally, programming skills for delivering high speed, high efficiency codes are introduced with special emphasis on commonly used tips, vectorized programming…

    • 2168 Words
    • 10 Pages
    Powerful Essays
  • Better Essays

    Chapter 2 Chapter 3 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 12 Chapter 16 Chapter 18 124 147 151 161 164 165 167 169 174…

    • 41203 Words
    • 165 Pages
    Better Essays
  • Satisfactory Essays

    same initial iterate p0 used in 2(iv). Give your approximation pn for the non-trivial root…

    • 309 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Cobweb

    • 1567 Words
    • 8 Pages

    A classic definition of the cobweb model is the one given by Ezekiel (1938) who…

    • 1567 Words
    • 8 Pages
    Powerful Essays
  • Powerful Essays

    Interior point method

    • 5498 Words
    • 37 Pages

    this requirement does not seem to be particularly restrictive, but it can be costly in computation.…

    • 5498 Words
    • 37 Pages
    Powerful Essays
  • Powerful Essays

    Cs1010E

    • 1015 Words
    • 5 Pages

    The lab component for the module will consist of three self-study sessions and one assignment which will count towards 5% of your final grade. Aim: Students are expected to learn basic skills in one of the following scientific computation software: MATLAB or scilab, and make use of the software to graph and solve mathematical problems involving differential equations and linear algebra. Deadline for submission of Lab Assignment:  1 pm Tuesday 22nd March 2011 Lab Sessions:  There will be three lab worksheets altogether  Students are to download the worksheets from IVLE Workbin  Students are expected to work on the worksheets during their free time  MATLAB is installed in S17-#03-03. Students may access these two labs during office hours for their practice  scilab will be available for download from the Workbin  The lab exercises are meant to complement the lectures. For maximum learning students are recommended to work on the worksheets according to the following schedule. Schedule: Week 3 Week 5 Weeks 6 - 9 Term Break 22nd Feb 2011 22nd Mar 2011 Worksheet 1 Worksheet 2 Weekly Clinic sessions Worksheet 3 Assignment worksheet available Deadline for assignment submission…

    • 1015 Words
    • 5 Pages
    Powerful Essays

Related Topics