急救:如何用matlab语言绘制一个长方形,将长方形3等分,每份分别着不同的...
rectangle('position',[2,3,6,3]);%画长方形 hold on;x1=4;y1=3:0.01:6;x2=6;y2=3:0.01:6; %将长方形3等分 plot(x1,y1,x2,y2);hold on;x1=[2,4,4,2];y1=[3,3,6,6];patch(x1,y1,'r');x2=[4,6,6,4];y2=[3,3,6,6];patch(x2,y2,'b');x3=[6...
matlab,将一个边长为3的正方形分成九等分,并在每份中着不同的颜色。求...
代码如下:width=3;height=3;figure;rectangle('Position',[0,0,width,height])axis offcolors=parula(width*height);for i=1:height for j=1:width rectangle("Position",[j-1,i-1,1,1],"FaceColor",colors(i*j,:)); endend运行结果: