Unformatted text preview: also an array.
>> x = roots([a b c]) % values in square brackets creates an array
>> p = [a b c];
>> x = roots(p);
>> x(1) % x(1) is the firstelement of the result
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 = 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.
- Spring '10