0% found this document useful (0 votes)
94 views8 pages

Mat-Lab Manual Part 2

This document contains a MATLAB manual with examples of: 1. Determining if a matrix is singular or non-singular by calculating the determinant and inverse. 2. Solving simultaneous equations using Cramer's rule by calculating determinants. 3. Demonstrating the logarithmic identity log(AB) = logA + logB and log(A/B) = logA - logB. 4. Plotting straight lines with different attributes like slope and intercept. 5. Integrating and differentiating sin(x) and plotting the results on the same graph in different colors along with sin(x).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views8 pages

Mat-Lab Manual Part 2

This document contains a MATLAB manual with examples of: 1. Determining if a matrix is singular or non-singular by calculating the determinant and inverse. 2. Solving simultaneous equations using Cramer's rule by calculating determinants. 3. Demonstrating the logarithmic identity log(AB) = logA + logB and log(A/B) = logA - logB. 4. Plotting straight lines with different attributes like slope and intercept. 5. Integrating and differentiating sin(x) and plotting the results on the same graph in different colors along with sin(x).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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

Page1

MAT-LAB MANUAL PART 2

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

Page2

MAT-LAB MANUAL PART 2


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));

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

Page3

MAT-LAB MANUAL PART 2

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

Page4

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

Page5

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

Page6

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

Page7

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

Page8

You might also like