0% found this document useful (0 votes)
69 views5 pages

National University OF Modern Languages: Project

This document is a project report submitted by 4 students - Ayesha Akram, Umer Mehmood, Sami Ullah, and Asif Abbas - to Dr. M Javad Ur Rehman of the Department of Software Engineering at National University of Modern Languages. The report describes a MATLAB code for linear regression that takes user input of x and y values, fits the data to a polynomial model, and outputs the polynomial equation. It provides examples of generating the A and B matrices for polynomial fits of different orders and generating the output polynomials.

Uploaded by

Ayesha Akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views5 pages

National University OF Modern Languages: Project

This document is a project report submitted by 4 students - Ayesha Akram, Umer Mehmood, Sami Ullah, and Asif Abbas - to Dr. M Javad Ur Rehman of the Department of Software Engineering at National University of Modern Languages. The report describes a MATLAB code for linear regression that takes user input of x and y values, fits the data to a polynomial model, and outputs the polynomial equation. It provides examples of generating the A and B matrices for polynomial fits of different orders and generating the output polynomials.

Uploaded by

Ayesha Akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

National University of Modern language

DEPARTMENT OF SOFTWARE ENGINEERING

NATIONAL UNIVERSITY
OF
MODERN LANGUAGES

LINEAR ALGEBRA

PROJECT

CLASS: BSSE (3-A)


GROUP N0: 5
GROUP MEMBERS:
 AYESHA AKRAM (12362)
 UMER MEHMOOD (12364)
 SAMI ULLAH (12349)
 ASIF ABBAS (12347)
SUBMITTED TO: Dr. M Javad Ur Rehman

NUML-F20-17721 BSSE-3A NUML-


ISB
National University of Modern language
DEPARTMENT OF SOFTWARE ENGINEERING

MATLAB CODE:

X = input('Enter list of abscissas : ');


Y = input('Enter list of ordinates : ');
F = input('Enter [1] for 2x2 fit [2] for 3x3 and [3] for 4x4 : ');
n = length(X);
N = F+1; % For dimension of matrix A
A = zeros(N,N); % Initializing the matrix A with N rows and N
columns

for i=1:N % For Rows


for j=1:N % For Columns
A(i,j) = sum(X.^(i+j-2)) % To compare powers of X the
subscripts in a matrix (generally subscript's values are 'a+2=x')
end % sum(Matrix.^(value)) is a general
MATLAB command to find sumissions (i.e.) 'E X^2 == sum(X.^2)'
end
% A % Getting A

B = zeros(N,1); % Initializing B martix with N rows and 1


column

for k=1:N % Column is static '1' so only one


loop for rows
B(k) = sum((X.^(k-1)).*Y); % To find B matrix (i.e.) 'E
x^N-1 * Y' in accordance with the pattern of B matrix
end
% B % Getting B

U = A\B % MATLAB built-in command to find unknowns

disp('Polynomial is : ') % Presenting in 'g(x) = a +


bx + cx^2' format
for k=N:-1:2
fprintf('+(%.4fx^%d') ,U(k), k-1)
end
fprintf('+(%.4f)\n',U(1))

NUML-F20-17721 BSSE-3A NUML-


ISB
National University of Modern language
DEPARTMENT OF SOFTWARE ENGINEERING

TEST OUPUTS:

- Finding ‘A’ matrix for 2x2

- Finding ‘A’ matrix for 3x3

NUML-F20-17721 BSSE-3A NUML-


ISB
National University of Modern language
DEPARTMENT OF SOFTWARE ENGINEERING

- Finding ‘B’ matrix for 3x3

NUML-F20-17721 BSSE-3A NUML-


ISB
National University of Modern language
DEPARTMENT OF SOFTWARE ENGINEERING

- Generating polynomial for 2x2 matrix

- Generating polynomial for 5x5 matrix

NUML-F20-17721 BSSE-3A NUML-


ISB

You might also like