How to change the colour of my line code

19 ビュー (過去 30 日間)
Jhon Rackham
Jhon Rackham 2020 年 4 月 25 日
コメント済み: Star Strider 2020 年 4 月 25 日
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 Center および File ExchangeMathematics についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by