Patch color error "Vectors must be the same length."
显示 更早的评论
I am trying to plot 2 patchs with different color. " patch(x, y, c, 'FaceColor', 'flat');" shows error "Vectors must be the same length.". How to setup the color?
x =[ 1 2
1 2
2 3
2 3];
y =[1 2
2 3
2 3
1 2];
c=[0 0.7344
0 1.0000
0.5156 0.2656];
figure;
patch(x, y, 'r');
figure;
patch(x, y, c, 'FaceColor', 'flat');
Thanks,
cfy30
2 个评论
Geoff Hayes
2020-6-29
cfy30 - which of the effects from C - polygon colours are you interested in? Because that will tell you what the dimensions for C should be.
cfy30
2020-6-29
采纳的回答
更多回答(1 个)
Ameer Hamza
2020-6-29
编辑:Ameer Hamza
2020-6-29
Using for-loop seems to be the simplest solution in this case.
x =[ 1 2
1 2
2 3
2 3];
y =[1 2
2 3
2 3
1 2];
c=[0 0.7344
0 1.0000
0.5156 0.2656];
figure;
for i=1:size(x,2)
patch(x(:,i), y(:,i), c(:,i).');
end

类别
在 帮助中心 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!