我正在尝试在 MATLAB 中保存多个具有不同颜色的圆圈的 png 文件。我希望有多个名称为:
RINGS_Base_<n><colorname>
n
是显示的不同文件的数量,colorname
是圆圈颜色的名称。
由于圆圈具有 RGB 颜色,因此我使用函数 translatecolor 将每种 RGB 颜色转换为颜色的实际名称。
我可以在命名每个文件时调用该函数吗?如果没有,我怎样才能用它们各自的颜色命名所有文件?
预先感谢您的帮助。
这是我的代码:
RGB = [1 1 0; 1 0 1; 0 1 1; 1 0 0; 0 1 0; 0 0 1];
%
%RIGNSGenerator_FilledCircle1
%
n=1;
for col1 = transpose(RGB)
FilledCircle1(2,2,5,300,transpose(col1)) %function []=FilledCircle1(x0,y0,Radius,N,col1)
print (strcat ('/Users/Stimuli_Rings/RINGS_Circle_', num2str(n),translatecolor(col1), '.png'), '-dpng') %strcat is to combining strings together
n=n+1;
end
function out=translatecolor(in) % translates the RGB colour into the actual name of the color
switch(in)
case [1 1 0], out='yellow';
case [1 0 1], out='pink';
case [0 1 1], out='cyan';
case [1 0 0], out='red';
case [0 1 0], out='green';
case [0 0 1], out='blue';
return;
end
end