You are not filling all values in QQQQ
, only those which will be in red. The rest (which should be in black) are left as empty cells, and thus they are not shown.
To correct this, You need to initialize QQQQ
to AAA
, and then modify color for the relevant cells. So, add
AAA = reshape(strtrim(cellstr(num2str(TTT(:)))), size(TTT));
QQQQ = AAA;
right before the for
loop, and remove the AAA = reshape...
line from within the loop. That is:
TTT = rand(30,2);
AAA = reshape(strtrim(cellstr(num2str(TTT(:)))), size(TTT));
QQQQ = AAA;
for u = 1:2
PPP = TTT(1:30, u:u);
RRR = ( PPP(:) > .5);
QQQQ(RRR, u) = strcat(...
'<html><span style="color: #FF0000; font-weight: bold;">', ...
AAA(RRR, u), ...
'</span></html>');
end
%# create table
f = figure;
h = uitable('Parent',f, 'Units','normalized', 'Position',[0.05 0.05 0.9 0.9]);
%# set table data
set(h, 'Data',QQQQ)