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

采纳的回答

Nicola Caldognetto
Nicola Caldognetto 2021-10-18
The issue was the CSI symbols where set all to zero

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by