Wrong colour mapping between graph and legend
1 view (last 30 days)
Show older comments
Nicola Caldognetto
on 18 Oct 2021
Answered: Nicola Caldognetto
on 18 Oct 2021
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!