Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
38 views

Matlab Programs For Computational Geomatery Q1) Program To Generate A Matrix

This document contains 30 questions and MATLAB code snippets demonstrating various computational geometry and image processing techniques including: 1. Generating and manipulating matrices through operations like addition, subtraction, multiplication, and transposition. 2. Plotting geometric shapes like spheres, cylinders, and cones. 3. Plotting common functions like sin, cos, and tan over various ranges. 4. Reading and manipulating image data through operations like edge detection, intensity adjustment, averaging, and rotation.

Uploaded by

Aasif Aftab
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Matlab Programs For Computational Geomatery Q1) Program To Generate A Matrix

This document contains 30 questions and MATLAB code snippets demonstrating various computational geometry and image processing techniques including: 1. Generating and manipulating matrices through operations like addition, subtraction, multiplication, and transposition. 2. Plotting geometric shapes like spheres, cylinders, and cones. 3. Plotting common functions like sin, cos, and tan over various ranges. 4. Reading and manipulating image data through operations like edge detection, intensity adjustment, averaging, and rotation.

Uploaded by

Aasif Aftab
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

MATLAB PROGRAMS FOR COMPUTATIONAL GEOMATERY

Q1) Program to generate a matrix.

A = [123;456;789]

Q2) Basic function to generate matrices.

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

Q3 Concatenate the matrices

B = [A A+32; A+48 A+16]

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]

Q5) Matrix Addition

A+B

Ans= 2 4 6
3 5 7
8 0 1

Q6) Matrix Substraction

A-B

Ans= 0 0 0
1 1 1
-1 -1 -1

Q7) Matrix Element by Element multiplication

A.*A

Ans= 1 4 9
4 9 16
9 16 25

Q8) Matrix Element by Element division

A./B

Ans= 1.0000 1.0000 1.0000


2.0000 1.5000 1.3333
0.7500 0.8000 0.8333

Q9) Matrix Element by Element left division

A.\B

Ans= 1.0000 1.0000 1.0000


0.5000 0.6667 0.7500
1.3333 1.2500 1.2000

Q10) Matrix Element by Element power

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

Q12.1) Draw a Sphere

[x,y,z] = sphere(10);
surf(x,y,z);

Q12.2) Draw a Sphere

[x,y,z] = sphere(40);
surf(x,y,z);
Q13.1) Draw a Cylinder

[x,y,z] = Cylinder(5);
surf(x,y,z);

Q13.2) Draw a Cylinder

[x,y,z] = Cylinder(20);
surf(x,y,z);

Q14) Draw a cone

cylinder([1 0])
Q15) Invert a cone

cylinder([0 1])

Q16) Draw the figure like this:

cylinder([1 0]);
hold on
cylinder([0 1]);

Q17) Draw a 3D hut.

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

Q30) Display the negative of an image by adjusting its intensities.

clc;
clear;
f=imread(‘peppers.png’);
n=imadjust(f, [0 1] , [1 0]);
imshow(n);

You might also like