Professional Documents
Culture Documents
Debanik Majumder
DIGITAL ASSIGNMENT - 1
Ans:-
An M-file or script file, is a simple text file where you can place MATLAB commands.
When the file is run,MATLAB reads the commands and executes them exactly as it would if you
have typed each command sequentially at the MATLAB prompt. All M-file names must end with
the extension '.m'.
Editor window:-
clc
clearvars
syms x y z
eqn1=x+3*y+3*z==1;
eqn2=2*x+6*y+9*z==5;
eqn3=-x-3*y+3*z==5;
[A,B]=equationsToMatrix([eqn1,eqn2,eqn3],[x,y,z])
x=linsolve(A,B)
Command window:-
A=
[ 1, 3, 3]
[ 2, 6, 9]
[ -1, -3, 3]
B=
1
5
5
x=
-2
0
1
Editor window:-
M=[1 3 -1 6;2 4 0 -1;0 -2 3 -1;-1 2 -5 1]
N=[-1 -3 3;2 -1 6;1 4 -1;2 -1 2]
a=M*N
e=eig(M)
Command Window:-
M=
1 3 -1 6
2 4 0 -1
0 -2 3 -1
-1 2 -5 1
N=
-1 -3 3
2 -1 6
1 4 -1
2 -1 2
a=
16 -16 34
4 -9 28
-3 15 -17
2 -20 16
No, the order of multiplication cannot be switched because matlab shows error.
Error using *
Inner matrix dimensions must
agree.
Eigen value of M-
e=
6.4217 + 0.0000i
0.9472 + 2.2913i
0.9472 - 2.2913i
0.6840 + 0.0000i