The function rectangle only accepts one face color and one edge color, so it cannot be used for plotting multiple edge colors. But it is easy to use patch, which allows a lot more control over the colors, including each edge having a different color:
>> X = [0,1,1,0]; >> Y = [0,0,2,2]; >> C = [1,0,0;0,1,0;0,0,1;1,1,0]; >> patch(X,Y,'FaceVertexCData',C,'EdgeColor','flat','FaceColor','none','LineWidth',2) >> set(gca,'visible', 'off');
giving: