How to change the colour of my line code

32 次查看(过去 30 天)
Hi guys, i need your help, I'm working on a line codificator and when I push the buttom for represent it, It appear with a remix of colours, I wanna know if I can change it for only 1 colours. This is my code:
a=str2double(get(handles.uno,'String'));
b=str2double(get(handles.dos,'String'));
c=str2double(get(handles.tres,'String'));
d=str2double(get(handles.cuatro,'String'));
e=str2double(get(handles.cinco,'String'));
f=str2double(get(handles.seis,'String'));
g=str2double(get(handles.siete,'String'));
h=str2double(get(handles.ocho,'String'));
i0=str2double(get(handles.nueve,'String'));
j0=str2double(get(handles.diez,'String'));
handles.bits=[a,b,c,d,e,f,g,h,i0,j0];
handles.cod=get(hObject,'Value');
hold off;
h =handles.bits;
n=1;
h(11)=1;
while n<=10;
t=n-1:0.001:n;
%Graficación de los CEROS (0)
if h(n) == 0
if h(n+1)==0
y=(t>n);
else
y=(t==n);
end
d=plot(t,y);title('Code UNIPOLAR RZ');grid on
set(d,'LineWidth',2.5);
hold on;
axis([0 10 -1.5 1.5]);
%Graficación de los UNOS (1)
else
if h(n+1)==0
y=(t<n-0.5);
else
y=(t<n-0.5)+1*(t==n);
end
d=plot(t,y);title('Code UNIPOLAR RZ');grid on;
set(d,'LineWidth',2.5);
hold on;
axis([0 10 -1.5 1.5]);
end
n=n+1;
end

采纳的回答

Star Strider
Star Strider 2020-4-25
The easiest way to set them all to the same colour is to subscript both the ‘d’ handles:
d(n)=plot(t,y);
then after the loop add:
set(d, 'Color','k')
to set them all to black ('k'), or substitute 'k' for whatever colour you want.
.
  4 个评论
Jhon Rackham
Jhon Rackham 2020-4-25
Star Strider, I'm trying your method but It fail, can you give me an example using part of my own code please?
Star Strider
Star Strider 2020-4-25
I do not have the information you used with the code you posted, so I cannot run it. (I tried that first, then created my own demonstration code when I could not run yours.)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by