2015F001/Homework8

From CDS 130

Jump to: navigation, search

Contents

  1. Image manipulation
  2. Using fill or image
  3. Color map and images
  4. Create images
  5. Plots
  6. making polygon shapes

1. Image manipulation

  • Create a 10x10 matrix that contains any number from 1 through 10 at least once. The numbers may be in any order. Create the matrix using a double for loop.
  • Create a colormap matrix such that each number is mapped to a unique color.
  • Use the image command to plot your image.
  • Use the colorbar command to show a colorbar.
  • Describe (in words) how you could change the colormap matrix to achieve the same result.

2. Using fill or image

Write a MATLAB code that draws 8-by-8 checkerboard with red and black tiles.

3. Color map and images

Write a Matlab script to create an image as follows: ( Note: you need to provide seven colors and the correct orientation of the strips.)

Image:strips.jpg

4. Create images

Run the following Matlab code.

clear;
i=0:2*pi/1000:2*pi;
x=sin(i); 
y=cos(i); 
fill (x,y, 'r', 'EdgeColor', 'r'); 
hold on
fill (x*0.98, y*0.98, 'b', 'EdgeColor', 'b');
hold off
axis equal off
shg

Understand the meaning of this code. Now, make use of this script and write a MATLAB code to generate the Target logo.

[[


Image:Target_logo.jpg]]


Your Image:

MATLAB code:

5. Plots

(a) Plot the following equations, first by choosing points within the range as a vector, computing the associated y values, and finally by building a proper plot using MATLAB statements.


0 < x < 4π, y = \frac{1}{16} sin (x^4) - \frac{1}{8} cos(x^3) + \frac{1}{4} sin(x^2)-\frac{1}{2}cos(x)


Plot:

MATLAB code:


6. making polygon shapes

Write a Matlab script to create an image as follows:


triangle


sorry, it took me a while to realize I was editing the primary homework page

Personal tools