0% found this document useful (0 votes)
2 views5 pages

B23366 Lab2

The lab report explores linear transformations, including matrix transformations, reflections, and rotations, focusing on their effects on a two-dimensional input space. It details the setup for visualizing these transformations using MATLAB, including grid generation and plotting techniques. The results illustrate how different transformation matrices alter the shape, orientation, and position of the grid in the input space.

Uploaded by

Kamal Yadav
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)
2 views5 pages

B23366 Lab2

The lab report explores linear transformations, including matrix transformations, reflections, and rotations, focusing on their effects on a two-dimensional input space. It details the setup for visualizing these transformations using MATLAB, including grid generation and plotting techniques. The results illustrate how different transformation matrices alter the shape, orientation, and position of the grid in the input space.

Uploaded by

Kamal Yadav
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/ 5

DS-412 Matrix Computations for

Data Science
Lab-2 Report
Ayush Sawarn
B23366

Date: February 23, 2025


Objectives
The primary aim of this lab is to explore and understand various types of linear trans-
formations, including matrix transformations, reflections, and rotations, and to visualize
their effects on a two-dimensional input space. This involves:

• Understanding Linear Transformations: To grasp the mathematical founda-


tions of linear transformations defined by the function.
• Matrix Representation: To represent these transformations using matrices and
comprehend how applying a transformation corresponds to matrix multiplication.
• Visualizing Input and Output Spaces: To generate a grid in the input space
and apply specified transformation matrices to visualize both the original input
space and the transformed output space. This includes plotting grid lines with
distinct styles for better clarity.
• Analyzing Transformations: To analyze the effects of different transformation
matrices on the input space, comparing original and transformed spaces through
graphical representations. This analysis will facilitate an understanding of how each
transformation alters the shape, orientation, and position of the grid.

Simulation Setup
1. Input Space Definition: - The input space is defined as R2 , where each point in
the space is represented as a vector [x, y]T . - The coordinate limits for both x and y are
set from -1 to 3, with unit spacing.

2. Grid Generation: - The ‘meshgrid‘ function in MATLAB is utilized to generate


a 2D grid of coordinate points. This function creates two matrices, ‘x‘ and ‘y‘, which
represent the x-coordinates and y-coordinates of the grid points, respectively. - The grid
points are generated over the specified range, resulting in a uniform distribution of points
in the input space.

3. Plotting Setup: - A new figure is initialized using the ‘figure‘ command to create
a visual representation of the input space and transformations. - The original input space
is plotted using solid red lines for horizontal grid lines and dashed blue lines for vertical
grid lines. The ‘plot‘ function is employed to achieve this, with ‘hold on‘ allowing multiple
plots within the same figure. - The ‘axis equal‘ command ensures that the aspect ratio of
the plot is maintained, allowing for accurate visual interpretation of distances and angles.

4. Matrix Transformations:
 
2 0
• T1 = (scaling transformation)
0 1
 
1 0
• T2 = (scaling transformation)
0 3
 
2 0
• T3 = (uniform scaling transformation)
0 2

1

1 −1
• T4 = √1 (reflection and rotation transformation)
1 1
2

 
1 0
• T5 = (reflection transformation)
0 −1
5. Transformation Application: - Each transformation matrix is applied to the
grid points stored in matrix ‘XY‘, which contains all x and y coordinates reshaped into
column vectors. - The transformed coordinates are computed by multiplying each trans-
formation matrix with the original coordinate matrix.

6. Visualization of Transformations: - For each transformation, separate subplots


are created using ‘subplot(2,3,n)‘ where ‘n‘ ranges from 2 to 6 to display transformed
spaces corresponding to each transformation matrix. - The transformed spaces are plotted
using similar styles (dashed blue for vertical and solid red for horizontal lines) as in the
original input space.

Results and Inference


1. Input Space: - Below is a visualization of the original input space generated by
MATLAB:

The generated input space consists of a uniform grid defined over the range from -1
to 3 for both x and y coordinates. The horizontal grid lines are represented by solid red
lines while vertical grid lines are shown as dashed blue lines. This visual representation
allows us to observe how points in R2 are distributed evenly across this defined area,

2
providing a clear foundation for applying linear transformations effectively.

2. Q1 Matrix Transformations: - Below is a visualization showing the effect of


various matrix transformations applied to the input space:

Each matrix transformation alters the shape and orientation of the original grid in distinct
ways:  
2 0
- Transformation T1 = : This scaling transformation stretches the grid hori-
0 1
zontally by a factor of 2 while leaving it unchanged vertically, resulting in an elongated
shape along the x-axis.  
1 0
- Transformation T2 = : This scaling transformation compresses the grid
0 3
vertically by a factor of 3 while maintaining its horizontal dimensions, leading to a taller
and narrower shape.  
2 0
- Transformation T3 = : This uniform scaling transformation enlarges both
0 2
dimensions equally by a factor of 2, resulting in a uniformly stretched grid that retains

3
its proportions.

3. Q2 Reflection and Rotation Transformations:

 
√1
1 −1
- Transformation T4 = : This reflection and rotation transformation
2 1 1
reflects points across the line y = x while rotating them counterclockwise by 45◦ , altering
both shape orientation and position.
 
1 0
- Transformation T5 = : This reflection transformation flips points across
0 −1
the x-axis, resulting in an inverted version of the original grid.

You might also like