- I dont understant about the Vandermonde matrix in Predicting the US population that is used in MATLABMATLAB Examples
9 views (last 30 days)
Show older comments
MATLABMATLAB Examples Predicting the US Population
Let's fit the data with a polynomial in t and use it to extrapolate to t = 2010. The coefficients in the polynomial are obtained by solving a linear system of equations involving a 11-by-11 Vandermonde matrix, whose elements are powers of scaled time, A(i,j) = s(i)^(n-j);
n = length(t); s = (t-1950)/50; A = zeros(n); A(:,end) = 1; for j = n-1:-1:1, A(:,j) = s .* A(:,j+1); end The coefficients c for a polynomial of degree d that fits the data p are obtained by solving a linear system of equations involving the last d+1 columns of the Vandermonde matrix:
A(:,n-d:n)*c ~= p
If d is less than 10, there are more equations than unknowns and a least squares solution is appropriate. If d is equal to 10, the equations can be solved exactly and the polynomial actually interpolates the data. In either case, the system is solved with MATLAB's backslash operator. Here are the coefficients for the cubic fit.
c = A(:,n-3:n)\p
0 Comments
Answers (1)
Sulaymon Eshkabilov
on 25 Jun 2021
Edited: Sulaymon Eshkabilov
on 25 Jun 2021
It is quite straightforward to employ the Vandermonde matrix for linear or quartic or cubic, etc. polynomial fit model, e.g:
P = [population data];
t = 1950:2010;
t = t-1950; % Data scaling
% Linear fit model
V1 = [t, ones(size(t))]; % Vandermonde matrix for Linear fit
FM = V1\P; % Fit model coefficients
FM_val = FM(1)*t+FM(2); % Fit model values
% Quadratic fit model
V2 = [t.^2, t, ones(size(t))]; % Vandermonde matrix for Quadratic fit
FM = V2\P; % Fit model coefficients
FM_val = FM(1)*t.^2+FM(2)*t+FM(3); % Fit model values
...
0 Comments
See Also
Categories
Find more on Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!