10
MAT-LAB MANUAL PART 2 1. Givin matrix singular and Non singular clc; close all; clear all; a= input('enter the given matrix='); disp('a='); disp(a); y=det(a); disp(y); y1=inv(a); disp(‘y1=’); disp(y1); DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 1

MAT.doc

Embed Size (px)

Citation preview

Page 1: MAT.doc

MAT-LAB MANUAL PART 2

1. Givin matrix singular and Non singular

clc;close all;clear all;a= input('enter the given matrix=');disp('a=');disp(a);y=det(a);disp(y);y1=inv(a);disp(‘y1=’);disp(y1);

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 1

Page 2: MAT.doc

MAT-LAB MANUAL PART 2

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 2

Page 3: MAT.doc

MAT-LAB MANUAL PART 2

2. Solve simultaneous equations (maximum of three) using Cramer’s rule

clc;close all;clear all;A=input ('enter the matrix A=');disp(A);b=input('enter the matrix b=');disp(b);A1=A;A1(:,1)=b;A2=A;A2(:,2)=b;A3=A;A3(:,3)=b;D=det(A);disp('D=');disp(D);D1=det(A1);disp('D1=');disp(D1);D2=det(A2);disp('D2=');disp(D2);D3=det(A3);disp('D3=');disp(D3);x(1)=D1/D;disp('x(1)=');disp(x(1));x(2)=D2/D;disp('x(2)=');disp(x(2));x(3)=D3/D;disp('x(3)=');disp(x(3));

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 3

Page 4: MAT.doc

MAT-LAB MANUAL PART 2

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 4

Page 5: MAT.doc

MAT-LAB MANUAL PART 2

3. Show that log10(A*B)=log10 A+ log10 B

clc;close all;clear all;a=2;disp('a=');disp(a);b=5;disp('b=');disp(b);y1=log(a*b);disp('y1=');disp(y1);y2=log(a)+log(b);disp('y2=');disp(y2);

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 5

Page 6: MAT.doc

MAT-LAB MANUAL PART 2

log10(A/B)=log10 A-log10 B

clc;close all;clear all;a=2;disp('a=');disp(a);b=5;disp('b=');disp(b);y1=log(a/b);disp('y1=');disp(y1);y2=log(a)-log(b);disp('y2=');disp(y2);

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 6

Page 7: MAT.doc

MAT-LAB MANUAL PART 2

4. Plot a straight line for the given slope and intercept using different plot attributes.

clc;close all;clear all;plot([2,-4],[1,6]);hold on;plot([5,-2],[-3,5]);xlabel('x axis');ylabel('y axis');title('plot a straight line');

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 7

Page 8: MAT.doc

MAT-LAB MANUAL PART 2

5. Integrate and differentiate sin(x) and display the results on the same plot in different colors. Also display sin(x) on the same plot

clc;close all;clear all;x=0:0.1:10;y=sin(x);z=cumsum(y)*0.1;subplot(1,3,1);plot(x,z,'r');title('integration');step=0.001;x=0:step:2*pi;y=sin(x);z=diff(sin(x))/step;subplot(1,3,2);plot(y,'m');subplot(1,3,3);plot(z,'g');title('differentiation');

DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page 8