MATLABŪ Getting Started Guide - The MathWorks - #201

/ 250


catalogue search
P. 201
P. 202
P. 203
P. 204
P. 205
P. 206
P. 207
P. 208
P. 209
P. 210
P. 211
P. 212
P. 213
P. 214
P. 215
P. 216
P. 217
P. 218
P. 219
P. 220
P. 221
P. 222
P. 223
P. 224
P. 225
P. 226
P. 227
P. 228
P. 229
P. 230
P. 231
P. 232
P. 233
P. 234
P. 235
P. 236
P. 237
P. 238
P. 239
P. 240
P. 241
P. 242
P. 243
P. 244
P. 245
P. 246
P. 247
P. 248
P. 249
P. 250


See other catalogues for The MathWorks

Text version of the page
Modeling Data
Modeling Data
In this section...
"Overview" on page 5-27 "Polynomial Regression" on page 5-27 "General Linear Regression" on page 5-28
Overview
Parametric models translate an understanding of data relationships into analytic tools with predictive power. Polynomial and sinusoidal models are simple choices for the up and down trends in the traffic data.
Note This section continues the data analysis from "Visualizing Data" on page 5-14.
Polynomial Regression
Use the polyfit function to estimate coefficients of polynomial models, then use the polyval function to evaluate the model at arbitrary values of the predictor.
The following code fits the traffic data at the third intersection with a polynomial model of degree six:
c3 = count(:,3); % Data at intersection 3
tdata = (1:24)';
p_coeffs = polyfit(tdata,c3,6);
figure
plot(c3,'o-')
hold on
tfit = (1:0.01:24)';
yfit = polyval(p_coeffs,tfit);
plot(tfit,yfit,'r-'.'LineWidth',2)
legend( 'Data','Polynomial Fit' .'Location'/NW')
5-27

pageCatalog pdf di En 2012-06-22-01