From CDS 130

Jump to: navigation, search


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


4. Create images

Run the following Matlab code.

fill (x,y, 'r', 'EdgeColor', 'r'); 
hold on
fill (x*0.98, y*0.98, 'b', 'EdgeColor', 'b');
hold off
axis equal off

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



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)


MATLAB code:

6. making polygon shapes

Write a Matlab script to create an image as follows:


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

Personal tools