I'm trying to build a program to compute the error of the QR method with data points compared to the actual solution. I am already stuck on the basic first draft since the matrix dimensions do not agree and I do not know how to fix this in a way I can still use it as I use it below. Any help on this or general tips on how to build a program for this problem would be greatly appreciated!
Code:
for i=1:21
x(i) = (i-1)/20;
y(i) = x(i)^8;
end
A = makeVandermondeMatrix(x,8)
[Q,R] = qr(A,0);
c = Q' .*y .* inv(R);
where makeVandermondeMatrix is:
function A = makeVandermondeMatrix(x, r)
n = size(x,2);
A = ones(n,r);
for i=1:r+1
A(:,i) = x.^(r-i+1);
end