How can I use RGB value?

조회 수: 5 (최근 30일)
Artem
Artem 2012년 10월 27일
Hello! Here is my problem.
I have a code for pop-up menu:
popupmenu=uicontrol(gcf,'Style', 'popup',...
'String', 'Blue|Green|Red|Brown|Grey|Purple|Pink',...
'Position', [100 100 100 50],...
'Callback',...
['sp_col=[''b'',''g'',''r'',''W'',''W'',''W'',''m''];',...
'set(sp,''Color'',sp_col(get(popupmenu,''Value'')));',...
'sp_col=sp_col(get(popupmenu,''Value''));']);
I have RGB values:
brown = [0.5 0.25 0];
grey = [0.4,0.4,0.4];
purple=[0.5 0 0.5];
How can I use this values in my cod (instead of 'W')?
Sorry for my English.
Thank you,
Artem.

답변 (1개)

Walter Roberson
Walter Roberson 2012년 10월 27일
colors = [0 0 1; 0 1 0; 1 0 0; 0.5 0.25 0; 0.4 0.4 0.4; 0.5 0 0.5; 1 1 0];
(Note: I might have gotten the code for magenta wrong.)
Then,
'Callback', 'sp_col = colors(get(popumenu, ''Value''), :);'
  댓글 수: 2
Artem
Artem 2012년 10월 27일
colors = [0 0 1; 0 1 0; 1 0 0; 0.5 0.25 0; 0.4 0.4 0.4; 0.5 0 0.5; 1 1 0];
popupmenu=uicontrol(gcf,'Style', 'popup',...
'String', 'Blue|Green|Red|Brown|Grey|Purple|Pink',...
'Position', [100 100 100 50],...
'Callback', ['sp_col = colors(get(popumenu, ''Value''));','set(sp,''Color'',sp_col);']);
When I run the programm and choose some color in the menu, this error appears: Undefined function or variable 'popumenu'. Error while evaluating uicontrol Callback
Walter Roberson
Walter Roberson 2012년 10월 27일
Change popumenu to popupmenu

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by