Wrong colour mapping between graph and legend
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to visualize the 5G grid using the code
% PRINT GRAPH
chpLevel = struct();
chpLevel.PDSCH = 0.4;
chpLevel.DMRS = 1;
chpLevel.PTRS = 1.4;
chpLevel.CSI = 1.8;
grid = complex(zeros(carrier.NSizeGrid*12,carrier.SymbolsPerSlot,pdsch.NumLayers));
grid(pdschIndices) = chpLevel.PDSCH;
grid(dmrsIndices) = chpLevel.DMRS*dmrsSymbols;
grid(ptrsIndices) = chpLevel.PTRS*ptrsSymbols;
grid(csirsIndices) = chpLevel.CSI*csirsSymbols;
map = parula(64);
cscaling = 40;
im = image(cscaling*abs(grid(:,:,1)));
colormap(im.Parent,map);
% Add legend to the image
chpval = struct2cell(chpLevel);
clevels = cscaling*[chpval{:}];
N = length(clevels);
L = line(ones(N),ones(N), 'LineWidth',8); % Generate lines
% Index the color map and associated the selected colors with the lines
set(L,{'color'},mat2cell(map( min(1+clevels,length(map) ),:),ones(1,N),3)); % Set the colors according to map
% Create legend
fnames = {'PDSCH','DM-RS','PT-RS','CSI'};
legend(fnames{:});
axis xy
title('Carrier Grid Containing PDSCH, DM-RS and PT-RS')
xlabel('OFDM Symbols')
ylabel('Subcarriers')
The main issue is that the first three value of the legend ( 'PDSCH','DM-RS','PT-RS' ) have the correct matching between graph and legend color but 'CSI' stays blue on the graph and changes color only on the legend
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!