My task is to write MATLAB code to produce a 4-part logo as shown in the screenshot. The top left should be black and the bottom right should be white. The other
two colours should be chosen randomly by the program.

I have taken the following approach:
clear all
clc
close all
x = [1 4 1 4 1 6.5 7 7];
y = [3 4 5.5 5 8 7 8 3];
fill(x,y,'k')
which creates the upper left black part. I wonder if that approach is good enough and if it is, what is the next step. I thought of storing those two variables in a shape object or something (I’m not familiar with Matlab) and rotate it somehow. Could you help me with that?
The easiest way to do this all this, is to make sure that your center point (i.e. the point where the different colors meet), is positioned at
[0,0]. Then a rotation of the figure (by multiple of 90°) boils down to changing the sign of either thexand/oryvalues of your contour.If you need the figure to be at a point different from
[0 0], just add these coordinates after you did the rotation.So starting from your code, you can do this:
edit: Clarification for the
colandcvariables.The variable
colcontains the colors to be used in rgb style, where each row is a color.randgenerates uniformly random numbers in the range[0,1], which is also where the values for the colors are expected to be. In the code above a2x3random matrix is generated, so that means 2 random colors which fits perfectly within thecolmatrix.The variable
ccontains the center of your figure. If you look at the plot, the center will be at[5 6](so 5 along the x axis and 6 along the y axis). You could use two variables instead, but I think that keeping both together in a variable is easier to deal with. I would personally do the same for yourxandyvariables, as that would allow you to use rotation matrices more easily, but that’s just a matter of choice.