Matlab Final
Matlab Final
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
VARIABLE
STEP 6:TO SORT IN THE DESCENDING ORDER USE NEGATIVE SYMBOL FOR
1
MAT LAB MCA 2016-2019, CMS CBE
CODING
A=[3 7 5
6 8 3
0 4 2 ];
2
MAT LAB MCA 2016-2019, CMS CBE
OUTPUT
Original values of A
A=
78 23 10 100 45 5 6
Ans =
5 6 10 23 45 78 100
Ans =
78 23 10 100 45 5 6
A=
3 7 5
6 8 3
0 4 2
Sorted matrix
ans =
0 4 2
3 7 3
6 8 5
3
MAT LAB MCA 2016-2019, CMS CBE
ans =
0 4 2
3 7 3
6 8 5
ans =
3 5 7
3 6 8
0 2 4
ans =
6 8 3
3 7 5
0 4 2
>>
RESULT:
The above program is executed successfully and output is obtained
4
MAT LAB MCA 2016-2019, CMS CBE
DATE: 20.12.17
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
VALUES.
STEP 4: FIND THE SQUARE ROOT OF X,Y AND STORE THE RESULT IN A
SEPARATE VARIABLE R.
5
MAT LAB MCA 2016-2019, CMS CBE
CODING
figure
[x,y]=meshgrid(-8:.5:8);
R=sqrt(x.^2+y.^2)+eps;
z=sin(R)./R;
subplot(2,2,1)
mesh(x,y,z,'EdgeColor','black')
subplot(2,2,2)
surf(x,y,z)
colormap cool
subplot(2,2,3)
surf(x,y,z)
colormap cool%
alpha(.4)
subplot(2,2,4)
surf(x,y,z,'faceColor','magenta','EdgeColor','none')
camlight left% headlight|right|left
lighting phong%or flat|goraud|phong
6
MAT LAB MCA 2016-2019, CMS CBE
OUTPUT
RESULT:
The above program is executed successfully and output is obtained
7
MAT LAB MCA 2016-2019, CMS CBE
DATE: 05.01.18
AIM:
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
AND Y=SIN(X).
STEP5: CREATE PLOT WITH AND PASS CALCULATED VALUES TO THE GRAPH.
8
MAT LAB MCA 2016-2019, CMS CBE
CODING
%subplot(2,1,1)
title('3 different waves')
x=-pi:pi/20:pi;
y=sin(x);
plot(x,y,'--gd')
hold on
x=-pi:pi/20:pi;
y=sin(x-pi);
plot(x,y,':bs')
grid on;
hold off
%subplot(2,1,2)
figure
title('sin wave with line properties')
x=-pi:pi/20:pi;
y=sin(2*x);
plot(x,y,'-mo',...
'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10)
9
MAT LAB MCA 2016-2019, CMS CBE
OUTPUT:
FIGURE 1
FIGURE 2
RESULT:
The above program is executed successfully and output is obtained
10
MAT LAB MCA 2016-2019, CMS CBE
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
FUNCTION.
RELEVANT TITLE.
11
MAT LAB MCA 2016-2019, CMS CBE
CODING
myimage=imread('a.jpg');
subplot(2,2,1),image(myimage),title('it is a original image');
subplot(2,2,2),image(myimage(:,:,1)),title('red layer here');
subplot(2,2,3),image(myimage(:,:,2)),title('green layer here');
subplot(2,2,4),image(myimage(:,:,3)),title('blue layer here');
OUT PUT
RESULT:
The above program is executed successfully and output is obtained
12
MAT LAB MCA 2016-2019, CMS CBE
DATE:03.02.18
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
STEP 3: DECLARE A VARIABLE AND LINK A STORED BMP IMAGE WITH PATH.
STEP 6: CONVERT THE PICTURE FROM COLOR TO BLACK & WHITE USING
STEP 7: FOLLOW THE ABOVE STEPS FOR JPG FILE WITH DIFFERENT VARIABLE.
13
MAT LAB MCA 2016-2019, CMS CBE
CODING
% converting .bmp and .jpg file into greyscale and save the new file
A = 'D:\a.bmp';
B = imread(A,'bmp');
figure(1),imshow(B);
C = rgb2gray(B);
figure(2), imshow(C);
imwrite(C,'D:\ converted1.bmp','bmp')
D = 'D:\b.bmp';
E = imread(D,'bmp');
figure(3),imshow(E);
F = rgb2gray(E);
figure(4), imshow(F);
imwrite(F,'D:\converted.jpg','jpg')
14
MAT LAB MCA 2016-2019, CMS CBE
OUTPUT:
RESULT:
The above program is executed successfully and output is obtained
15
MAT LAB MCA 2016-2019, CMS CBE
DATE:15.02.18
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
GETHOSTADDRES.
16
MAT LAB MCA 2016-2019, CMS CBE
CODING:
function whoami
try
me = java.net.InetAddress.getLocalHost;
catch
error('unable to get local host address');
end
myname = me.getHostName;
myip = me.getHostAddress;
17
MAT LAB MCA 2016-2019, CMS CBE
OUTPUT
RESULT:
The above program is executed successfully and output is obtained
18
MAT LAB MCA 2016-2019, CMS CBE
DATE: 21.02.18
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
STEP 3: IMPORT APPLET VIEWER IN JAVA AND STORE IT INTO THE DECLARED
VARIABLE.
STEP 4: SET THE LAYOUT OF THE FRAME WITH GRID AND LOCATION.
SETP 5:NAME THE DISPLAY BOX USING LABEL PROPERTY AND WRITE CODE
19
MAT LAB MCA 2016-2019, CMS CBE
CODING
dbox=java.awt.Frame('hi folks');
dbox.setLayout(java.awt.GridLayout(2,1));
dbox.setLocation(250,250);
resize(dbox,200,100);
set(dbox,'background',[1,1,1]);
txt=java.awt.Label('click the button to exit',1);
but=java.awt.Button('exit button');
set(but,'background',[0.7,0.5,0.5]);
set(but,'MouseClickedCaLLbACK','dbox.dispose')
dbox.add(txt);
dbox.add(but);
dbox.show;
20
MAT LAB MCA 2016-2019, CMS CBE
OUT PUT:
RESULT:
The above program is executed successfully and output is obtained
21
MAT LAB MCA 2016-2019, CMS CBE
DATE:27.02.18
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
22
MAT LAB MCA 2016-2019, CMS CBE
CODING:
%Use the following matrices for questions 3 and 4
a = [1 2
3 4];
b = [8 -1
2 -3];
c = [3 -3
14
0 7];
d = [0 1 2
304
1 -2 -1];
e = [6 5
0 -3
2 1];
f = [2 5 -1
0 3 3];
p=a+b
q=d*c
%matrix tranpspose
r = transpose(d)
s = e.'
A = [3 2 -1
-1 3 2
1 -1 -1];
C = [10
5
-1];
result =A\C
23
MAT LAB MCA 2016-2019, CMS CBE
OUT PUT
ans =
7
A=
1 3 11
A=
16
14
3
9
6
B=
1 3 11
24
MAT LAB MCA 2016-2019, CMS CBE
8 9 15
13 6 2
C=
12 7
1 11
8 15
p=
9 1
5 1
q=
1 18
9 19
1 -18
r=
0 3 1
1 0 -2
2 4 -1
s=
6 0 2
5 -3 1
result =
-2.0000
5.0000
-6.0000
>>
RESULT:
The above program is executed successfully and output is obtained
25
MAT LAB MCA 2016-2019, CMS CBE
DATE:12.03.18
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
26
MAT LAB MCA 2016-2019, CMS CBE
CODING:
[x,y] = meshgrid(-5:0.1:5,-3:0.1:3);
g = x.^2 + y.^2;
contour(x,y,g)
print -depsgraph.eps
OUTPUT:
RESULT:
The above program is executed successfully and output is obtained
27
MAT LAB MCA 2016-2019, CMS CBE
DATE:23.03.18
AIM
ALGORITHM
STEP 2: WINDOWS=>RUN=>CMD=>MATLAB.
TO 30 INCREASING BY 5.
STEP 6:DISPLAY THE VALUES FROM THE ARRAY LIKE SUB SET LIKE ANY
28
MAT LAB MCA 2016-2019, CMS CBE
CODING
%Creating various subset of vectors and matrixes
x = 2:7
r = [4,16,5
12,14,7
1,3,11
8,9,15
13,6,2]
29
MAT LAB MCA 2016-2019, CMS CBE
OUTPUT
RESULT:
The above program is executed successfully and output is obtained
30