Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

TO ENTER AN EXPRESSION AND SOLVE

Aim: to enter an expression and solve using matlab software


Apparatus: personal computer
Matlab software
Program:
clc;
close all;
clear all;
x=input('enter value of x');
y=x^2+sin(x);
z=cos(x);
Answer=y/z

Result:

TO WORK WITH ARRAYS AND MATRICES


Aim: to find determinant, transpose, inverse of the matrix
Apparatus: personal computer
Matlab software
Programme:
clc;
clear all;
close all;
x=input('enter matrix x=');
disp('given matrix is=');
disp(x);
y=det(x);
disp('det of matrix is=');
disp(y);
z=x';
disp('transpose of matrix is=');
disp(z);
i=inv(x);
disp('inverse of matrix is=');
disp(i);

Result:

TO SOLVE SIMULTANEOUS EQUATIONS USING MATLAB


Aim: To Solve simultaneous equations using Matlab
Apparatus: personal computer
Matlab software
Programme:
clc;
clear all;
close all;
A=input('enter coefficient matrix A=');
B=input('enter constant matrix B=');
X=inv(A)*B;
disp('solution to the given equations is=');
disp(X);

RESULT:

TO SOLVE FOR CURRENTS IN AN ELECTRICAL CIRCUIT USING


KIRCHOFFS LAWS USING MATLAB

Aim: To solve for currents in an electrical circuit using kirchoffs laws using matlab
Apparatus: personal computer
Matlab software
Electrical Circuit:

Programme:
clc;
clear all;
close all;
A=input('enter coefficient matrix A=');
B=input('enter constant matrix B=');
I=inv(A)*B;
disp('currents in the meshs is=');
disp(I);
Result:

TO PLOT A GRAPH BETWEEN TWO VARIABLES


Aim: To plot sine wave using matlab
Apparatus: personal computer
Matlab software
Program:
clc;
close all;
clear all;
t=0:0.001:1;
f=input('enter value of frequency');
a=input('enter value of amplitute');
y=a*sin(2*pi*f*t);
plot(t,y);
xlabel('time');
ylabel('sine wave');
title('sine wave');

Result:

TO PLOT MULTIPLE FUNCTIONS AND ADD TITLE AND LABELS

Aim: To plot sine, cosine, ramp, step square signals in single plot
Apparatus: personal computer
Matlab software
Program:

TO USE FPLOT, EZPLOT AND EZSURFC FUNCTIONS


Aim: To use fplot , ezplotand ezsurfc functions
To publish a report in word file
Apparatus: personal computer
Matlab software
Program:
clc;
clear all;
close all;
figure;
fplot('exp(-.1*x).*sin(x)',[0 20]);
xlabel('x');
ylabel('functon');
title('plot using fplot command');
figure;
ezplot('exp(-.1*x).*cos(x)',[0 20]);
xlabel('x');
ylabel('functon');
title('plot using ezplot command');
figure;
z='-5./(1+x.^2+y.^2)';
ezsurf(z,[-3,3,-3,3])
xlabel('x');

ylabel('y');
zlabel('z');
title('plot using ezsurf command');
figure;
z='-5./(1+x.^2+y.^2)';
ezsurfc(z,[-3,3,-3,3])
xlabel('x');
ylabel('y');
zlabel('z');
title('plot using ezsurfc command');
Publishing Report:
To publish a report go to FILEPUBLISH filename.m
Results:

You might also like