matrix, with the following pixel colors: [white red black; cyan green yellow; black blue white] in matlab

You can create a matrix in MATLAB with the pixel colors [white red black; cyan green yellow; black blue white] using the following code:

main.m
my_matrix = [1 0 1; 0 1 1; 1 2 1];
35 chars
2 lines

Note that this assumes you have defined the color values for each of the colors (e.g. white = 1, red = 0, etc.) and that the matrix you want to create is a 3x3 matrix as shown. If the color values are not defined, you can assign them using the following code:

main.m
white = 1;
red = 0;
black = 2;
cyan = 3;
green = 4;
yellow = 5;
blue = 6;
74 chars
8 lines

Then you can create the matrix using the code above.

related categories

gistlibby LogSnag