Matrix

A Matrix is a rectangular array or table of numbers, symbols or expressions, arranged in rows and columns, which is used to represent a mathematical object or a property of such an object. For example, is a matrix with two rows and three columns.

Script:

clc                            

A=[2 4 6; 7 8 9;]

B=[11 9; 7 5; 3 1;]

C=A*B

D=B*A 

Script Analysis:

The above code where clc refers to clear all. clc clear all texts from the command window. Then, the array of A[] refers a 2x3 array and B[] refers a 3x2 array. The resulting Matrix solution for C is a 2x2 matrix and D is a 3x3 Matrix. The solution is shown below. 


Solving Equation

syms a b c x        

a=5;

b=7;

c=3;

%The equation is 5x^2+ 7x + 3 = 0

eqn= a*x^2 + b*x + c == 0

x=solve(eqn)





Loop

%code 3: Sum of 1 to 10 using loop

clc         %Clear all

n=10;

sum=0;

for i=0: 1 :n

    sum=sum+i;

end

SUM=sum     %display sum