Wrong colour mapping between graph and legend

조회 수: 1 (최근 30일)
Nicola Caldognetto
Nicola Caldognetto 2021년 10월 18일
답변: Nicola Caldognetto 2021년 10월 18일
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