Create a script that would solve a system of any number of l

Create a script that would solve a system of any number of linear equations that can differentiate between:(1) One solution and print out the list of values for every variable. (2) No solution(3) Infinite number of solutions Can you please write the code using Matlab! Also If you could write the code so I could just copy it into matlab that would be awesome. Comments would be appreciated. Thank you!

Solution

Here mat lab have the two commands which are helpfull to solve the linear equatins ...

1.lineSolve

2. Solve

1.lineSolve():-

In this method we gave the equations in the form of matrix that is AX=C here A is matrix which has the varibles base values and X also a no.of varibles * one columns matrix which has the constant values.

equationsToMatrix to convert the equations into the form AX = B. The second input to equationsToMatrix specifies the independent variables in the equations

Example :-

2x+y+z=2---->eq1

x+yz=3---->eq2

x+2y+3z=10---->eq3

MAT LAB code:

//here we draw extract the base values of varibles from the equations 1 2 3

A=

B=

From the B matrix we can get the x=3 and y=1 and z=-5

Here another example for linear eqution with out using linesolve and equtions matrix

our problem is:

3x-2y+4z=15--->eq1

10x+5y-15z=30--->eq2

12.5x+9y+10z=45---->eq3

MAT LAB code:

A=[3 -2 4;10 5 -15;12.5 9 10]// here manulay giving the values as matrix into A matrix

B=[15;30;45]

C=inv(A)// here inverser of A matrix

X=C*B

OUT PUT:

A=

3.0000 -2.000    4.000

10.000     5.000   -15.000

12.500      9.000    10.000

B=

15

30

45

C=

0.1491935     0.0451613     0.0080645

-0.2318548     -0.0161290   0.0685484

0.0221774       -0.0419355   0.0282258

X=

3.955565

-0.87702

0.34476

2)No Solution linear equtions

You can give the equtions with no solution eqution and infinete solutions by using solve equtions method

eqution--->2x+3=2x+7 example of no solution eqution

MATlab code:

syms x;

leq = 2*x+3=2*3+7;

3)
infinate solutions:

leq= 2*x+3=2*x+3;// this is infinte solutions

Create a script that would solve a system of any number of linear equations that can differentiate between:(1) One solution and print out the list of values for
Create a script that would solve a system of any number of linear equations that can differentiate between:(1) One solution and print out the list of values for

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site