Matlab Programs For Computational Geomatery Q1) Program To Generate A Matrix
Matlab Programs For Computational Geomatery Q1) Program To Generate A Matrix
Matlab Programs For Computational Geomatery Q1) Program To Generate A Matrix
A = [123;456;789]
Z = zeros(2,4)
Z= 0 0 0 0
0 0 0 0
F = 5*ones(3,3)
F= 5 5 5
5 5 5
5 5 5
N = fix(10*rand(1,10))
N= 9 2 6 4 8 7 0 8 4
Q4 Show the
sum of a matrix
sum(A) = 34 34 34 34
Transpose of a matrix
A’ = 16 5 9 4
3 10 6 15
2 11 7 14
13 8 12 1
Diagonal of a matrix
diag(A) = 16
10
7
1
******************************************************************
A=[1 2 3;2 3 4;3 4 5]
B=[1 2 3;1 2 3;4 5 6]
A+B
Ans= 2 4 6
3 5 7
8 0 1
A-B
Ans= 0 0 0
1 1 1
-1 -1 -1
A.*A
Ans= 1 4 9
4 9 16
9 16 25
A./B
A.\B
A.^2
Ans= 1 4 9
4 9 16
9 16 25
Q11) Build a table of integers from 0 to 9, their squares and their powers of 2.
N = (0:9)’;
Table = [N N.^2 2.^N]
Table = 0 0 1
1 1 2
2 4 4
3 9 8
4 16 16
5 25 32
6 36 64
7 49 128
8 64 256
9 81 512
[x,y,z] = sphere(10);
surf(x,y,z);
[x,y,z] = sphere(40);
surf(x,y,z);
Q13.1) Draw a Cylinder
[x,y,z] = Cylinder(5);
surf(x,y,z);
[x,y,z] = Cylinder(20);
surf(x,y,z);
cylinder([1 0])
Q15) Invert a cone
cylinder([0 1])
cylinder([1 0]);
hold on
cylinder([0 1]);
Cylinder([1 1,0]);
Q18) Plot the graph for x and y where the range of x is from 0 to 5 with intervals
at every 0.5 and y=exp(x)
clc;
clear;
x=0:0.5:5;
y=exp(x);
plot(x,y);
Q19) Plot the graph for x and y where the range of x is from 0 to 4 with intervals
at every 0.5 and y=sin(x)
clc;
clear;
x=0:0.5:4;
y=sin(x);
plot(x,y);
Q20) Plot the graph for x and y where the range of x is from 0 to 4 with intervals
at every 0.5 and y=cos(x)
clc;
clear;
x=0:0.5:4;
y=cos(x);
plot(x,y);
Q21) Plot the graph for x and y where the range of x is from 0 to 5 with intervals
at every 0.5 and y=tan(x)
clc;
clear;
x=0:0.5:5;
y=tan(x);
plot(x,y);
Q22) Plot the graph for x and y where the range of x is from 0 to 5 with intervals
at every 0.5 and show sin(x), cos(x), tan(x) simultaneously.
clc;
clear;
x=0:0.5:5;
y=sin(x);
plot(x,y);
hold on;
y=cos(x);
plot(x,y);
hold on;
y=tan(x);
plot(x,y);
Q23) Plot the graph for x and y where the range of x is from 0 to pi with
intervals at every pi/20 and y=exp(sin(x))
clc;
clear;
x=0:pi/20:pi;
y=exp(sin(x));
plot(x,y);
Q24) Plot the graph for x and y where the range of x is from 0 to 5 with intervals
at every 0.5 and y is the square of x.
clc;
clear;
x=0:0.5:5;
y=(x^2);
plot(x,y);
Q25) Plot the graph for x and y where the range of x is from 0 to 5 with intervals
at every 0.5 and y =2^x
clc;
clear;
x=0:0.5:5;
y=(2^x);
plot(x,y);
Q26) Read an image and display the minimum and maximum intensity values.
clc; clear;
f=imread(‘cameraman.tif’);
minimum=min(min(f));
maximum=max(max(f));
minimum
maximum
Q27) Detect the ‘edges’ of the image with two different methods and compare the
histograms.
clc; clear;
i=imread(‘cameraman.tif’);
bw1=edge(I,’sobel’);
bw1=edge(I,’canny’);
imshow(bw1);
imshow(bw2);
imhist(bw1);
imhist(bw2);
Q28) Find the average intensity value of an image.
clc;
clear;
f=imread(‘cameraman.tif’);
ave=mean(mean(f));
Q29) Display matrix values of the image and rotate the image by taking
transpose.
clc;
clear;
f=imread(‘cameraman.tif’);
f1=(f’);
imshow(f1);
clc;
clear;
f=imread(‘peppers.png’);
n=imadjust(f, [0 1] , [1 0]);
imshow(n);