0% found this document useful (0 votes)
31 views16 pages

Didar Matlab

The document is a MATLAB course submission that includes: - Course title: Linear Algebra & Vector Analysis - Course code: 105 - Section: DC - Date submitted: December 30, 2021 - Submitted by student Md Didar Bhuiyan to instructor Jakia Sultana of the Computer Science Engineering department at Green University of Bangladesh.

Uploaded by

Miyad Mohammad
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)
31 views16 pages

Didar Matlab

The document is a MATLAB course submission that includes: - Course title: Linear Algebra & Vector Analysis - Course code: 105 - Section: DC - Date submitted: December 30, 2021 - Submitted by student Md Didar Bhuiyan to instructor Jakia Sultana of the Computer Science Engineering department at Green University of Bangladesh.

Uploaded by

Miyad Mohammad
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/ 16

MATLAB

Course Title : Linear Algebra & Vector Analysis

Course code: 105

Section: DC

Date of submission: 30/12/2021

Submitted By: Submitted To:


Name: Md Didar Bhuiyan Jakia Sultana
ID: 211002038 Senior teacher
Department of CSE Dept. of CSE
Green University of Bangladesh Green University of Bangladesh
Code of 1 :
#include<stdio.h>
int main()
{
int i,j,m,n;
float A[20][20],c,a[20],sum=0.0;
printf("Enter the order of matrix : \n");
scanf("%d",&n);
printf("Enter your elements of augmented matrix : \n");
for(i=1; i<=n; i++)
{
for(j=1; j<=(n+1); j++)
{
printf("A[%d][%d] : ",i,j);
scanf("%f",&A[i][j]);
}
}
for(j=1; j<=n; j++)
{
for(i=1; i<=n; i++)
{
if(i>j)
{
c=A[i][j]/A[j][j];
for(m=1; m<=n+1; m++)
{
A[i][m]=A[i][m]-c*A[j][m];

}
}
}
}
a[n]=A[n][n+1]/A[n][n];
for(i=n-1; i>=1; i--)
{
sum=0;
for(j=i+1; j<=n; j++) {
sum=sum+A[i][j]*a[j];
}
a[i]=(A[i][n+1]-sum)/A[i][i];
}

printf("\n\nThe Result is : \n");


for(i=1; i<=n; i++)
{
printf("\na%d=%.2f\t",i,a[i]);
}
return 0;
}
Output:
Code:
#include<iostream>
using namespace std;
int main()
{

int i,j,k,order;
float M[20][20],r,p[10],sum=0.0; cout<<"\n";
cout<<"Enter the order of matrix: "; cin>>order;
cout<<"\n";
cout<<"Put(row-wise)the elements of augmented matrix:"; cout<<"\n";
for(i=1; i<=order; i++)
{

for(j=1; j<=(order+1); j++)


{

cin>>M[i][j];
}
}

cout<<"\n";
cout<<"Inputed matrix is: \n"; for(i=1; i<=order; i++){
for(j=1; j<=order+1; j++){ cout<<M[i][j] <<" "; cout<<"\t";
}

cout<<"\n";
}

for(j=1; j<=order; j++)


{

for(i=1; i<=order; i++)


{

if(i>j)
{

r=M[i][j]/M[j][j];
for(k=1; k<=order+1; k++)
{

M[i][k]=M[i][k]-r*M[j][k];
}
}
}
}

p[order]=M[order][order+1]/M[order][order]; for(i=order-1; i>=1; i--)


{

sum=0.0;
for(j=i+1; j<=order; j++)
{
sum=sum+M[i][j]*p[j];
}

p[i]=(M[i][order+1]-sum)/M[i][i];
}

cout<<"\n";
cout<<"\nThe solution is: \n";

cout<<"p= "<<p[1]<<endl; cout<<"q= "<<p[2]<<endl; cout<<"r= "<<p[3]<<endl;

Output:
Code:
#include<stdio.h>
int main()
{
int i,j,m,n;
float A[20][20],c,a[20],sum=0.0;
printf("Enter the order of matrix : \n");
scanf("%d",&n);
printf("Enter your elements of augmented matrix : \n");
for(i=1; i<=n; i++)
{
for(j=1; j<=(n+1); j++)
{
printf("A[%d][%d] : ",i,j);
scanf("%f",&A[i][j]);
}
}
for(j=1; j<=n; j++)
{
for(i=1; i<=n; i++)
{
if(i>j)
{
c=A[i][j]/A[j][j];
for(m=1; m<=n+1; m++)
{
A[i][m]=A[i][m]-c*A[j][m];

}
}
}
}
a[n]=A[n][n+1]/A[n][n];
for(i=n-1; i>=1; i--)
{
sum=0;
for(j=i+1; j<=n; j++) {
sum=sum+A[i][j]*a[j];
}
a[i]=(A[i][n+1]-sum)/A[i][i];
}

printf("\n\nThe Result is : \n");


for(i=1; i<=n; i++)
{
printf("\na%d=%.2f\t",i,a[i]);
}
return 0;
}

Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy