Skip to Main Content
Programming in MATLAB ®: A Problem-Solving Approach by Pearson
book

Programming in MATLAB ®: A Problem-Solving Approach by Pearson

by Ram N. Patel, Ankush Mittal
May 2024
Intermediate to advanced content levelIntermediate to advanced
433 pages
13h 7m
English
Pearson India
Content preview from Programming in MATLAB ®: A Problem-Solving Approach by Pearson
Recursive Functions É 155
The coefficients in the approximating polynomial of degree 5 are:
>> p = polyfit(x,y,5)
p =
-0.0076 0.0593 -0.0206 -0.4886 -0.0024 1.0001
There are six coefficients in p. To see how good the fit is, evaluate the polynomial at the
data points with the following:
>> f = polyval(p,x);
% A table showing the data, fit, and error is
>> table = [x y f y-f];
>> table(1:5,:)
ans =
% x y f y-f (error)
0 1.0000 1.0001 -0.0001
0.1000 0.9950 0.9949 0.0001
0.2000 0.9801 0.9800 0.0001
0.3000 0.9553 0.9553 0.0000
0.4000 0.9211 0.9211 -0.0000
From the above table, it can be seen that on this interval, the fit is good to three digits.
Let us evaluate the difference beyond the interval (0, pi) on which curve fitting was done.
>> x2 = pi * [11/10 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Applied Numerical Methods Using MATLAB, 2nd Edition

Applied Numerical Methods Using MATLAB, 2nd Edition

Won Y. Yang, Wenwu Cao, Jaekwon Kim, Kyung W. Park, Ho-Hyun Park, Jingon Joung, Jong-Suk Ro, Han L. Lee, Cheol-Ho Hong, Taeho Im
MATLAB Recipes: A Problem-Solution Approach

MATLAB Recipes: A Problem-Solution Approach

Michael Paluszek, Stephanie Thomas
Practical MATLAB Deep Learning: A Projects-Based Approach

Practical MATLAB Deep Learning: A Projects-Based Approach

Michael Paluszek, Stephanie Thomas, Eric Ham

Publisher Resources

ISBN: 9781306983440Publisher Website