How to change the colour of my line code
21 views (last 30 days)
Show older comments
Jhon Rackham
on 25 Apr 2020
Commented: Star Strider
on 25 Apr 2020
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287471/image.png)
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
0 Comments
Accepted Answer
Star Strider
on 25 Apr 2020
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 Comments
Star Strider
on 25 Apr 2020
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.)
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!