Upload
dayanand-gowda-kr
View
214
Download
0
Embed Size (px)
Citation preview
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
1/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page1
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);
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
2/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page2
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
3/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page3
2. Solve simultaneous equations (maximum of three) using Cramers 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));
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
4/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page4
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
5/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page5
3. Show that log10(A*B)=log10A+ log10B
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);
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
6/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page6
log10(A/B)=log10A-log10B
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);
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
7/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page7
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');
7/25/2019 2nd_sem_MAT_LAB_MANNUAL.PDF
8/8
MAT-LAB MANUAL PART 2
DAYANANDA GOWDA K R S.E.T.POLYTECHNIC MELKOTE Page8
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');