how can i display on a table's cell different colors ?

조회 수: 52 (최근 30일)
Stephani Kanga
Stephani Kanga 2020년 11월 11일
댓글: Stephani Kanga 2020년 11월 16일
I read the rgb values from an excel file and I want to show the color in a uitable cell.
I tried addStyle but it only works for uifigure while i'm working on figure and i also tried to change the background of the cell but the background changes for all the cells of the table. Is there a way to change the color of a specific cell ?

답변 (1개)

Eric Sofen
Eric Sofen 2020년 11월 12일
It sounds like you're on the right track. You want to apply the addStyle to the uitable, not the uifigure:
% setup
fig = uifigure;
fig.Position = [500 500 520 200];
uit = uitable(fig);
uit.Data = rand(5);
uit.Position = [20 30 480 135];
% add some color
s1 = uistyle('BackgroundColor','r');
addStyle(uit,s1,'column',3)
s2 = uistyle('BackgroundColor','b');
addStyle(uit,s2,'cell',[1 1; 2 4; 3 5;])
  댓글 수: 1
Stephani Kanga
Stephani Kanga 2020년 11월 16일
Yes, I've tried that but as i don't use uifigure it doesn't allow me to use addStyle on figure

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by