Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

'Enter The Matrix': For End For

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

EXP:

DATE:
QR DECOMPOSITION OF A MATRIX
PROGRAMMING CODE
Clc;
a=input('enter the matrix');
[m n] =size(a);
u = zeros(m,n);
e = zeros(m,n);
v=zeros(m,1);
r=zeros(m,n);
u(:,1) =a(:,1)
s =0;
for j = 1:n
s = s+u(j,1)*u(j,1);
end
e(:,1)=u(:,1)/sqrt(s)
for i=2:n
s=0;
t=0;
v=zeros(m,1);
for j=1:m
for p =1:i-1
t=dot(a(:,i),e(:,p))
v(j,1)=v(j,1)+t*e(j,p);
end
u(j,i) = a(j,i)-v(j,1);
s=s+(u(j,i)*u(j,i))
end
e(:,i)=u(:,i)/sqrt(s)
end
fprintf('the Q Matrix:');
e
fprintf('the R matrix is:');
R = e'*a
fprintf('the given matrix');
L=e*R

enter the matrix[12 -51 4;6 167 -68;-4 24 -41]


the Q Matrix:
e=

0.8571 -0.3943 -0.3314


0.4286
-0.2857

0.9029

0.0343

0.1714 -0.9429

the R matrix is:


R=

14.0000 21.0000 -14.0000


-0.0000 175.0000 -70.0000
-0.0000 -0.0000 35.0000

the given matrix


A=

12.0000 -51.0000

4.0000

6.0000 167.0000 -68.0000


-4.0000 24.0000 -41.0000

You might also like