02 Matlab and Roots I

# 8990 xfzerof4findrootinvicinityof4 x 68990

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: also an array. >> x = roots([a b c]) % values in square brackets creates an array x = ‐6.8990 2.8990 >> p = [a b c]; >> x = roots(p); >> x(1) % x(1) is the firstelement of the result ans = ‐6.8990 >> x(2) ans = 2.8990 Points to remember: • [v1 v2 v3 …. Vn] is a array • Array indices start at 1 (not at zero as in C++) • A(n) selects the nth element of array A 4 1/10/2013 Matlab Function “fzero” Function fzero is a general root finding function. In order to use it the function of interest must be defined: >> f = @(x) a*x^2 + b*x + c; fzero must be given either a range of interest or a ballpark value >> x = fzero(f, [0 4]) % find root between 0 and 4 x = 2.8990 >> x = fzero...
View Full Document

## This note was uploaded on 03/30/2013 for the course ECOR 2606 taught by Professor Goheen during the Spring '10 term at Carleton CA.

Ask a homework question - tutors are online