MATLAB: Hi i need to do heatmap and have some problem with histcounts functions and the map

heatmap

ok
so thats the problem –
i have vector d (size 5,000)
and i have matrix mat_X which show positions – every column show x positions over time for corresponding d in the vector (my original mat_X is 5000*5000 matrix)
so i want to built accumulated heat map of position along x (col from mat_X) for different d value (1position from the vector for the first col, 2 for 2nd and so on)
so for doing so, i need first to use histcounts for every col (since my data is not so small )
so i did this loop
bins=50;
Accumulated_Prob=zeros(bins,length(d));
for i=1:length(d)
[P,cc] = histcounts(mat_X(:,i),bins,'normalization','probability');
Accumulated_Prob=Accumulated_Prob+P';
end
heatmap(Accumulated_Prob)
title('Accumulated Heat Map of RF x position, Vf at x=-1')
xlabel('d')
ylabel('x')
but… i get only black graph…
i would appreciate help !

Best Answer

  • You have to save the values into a matrix in loop, which you are not doing.
    bins=50;
    Accumulated_Prob=zeros(bins,length(d));
    for i=1:length(d)
    [P,cc] = histcounts(mat_X(:,i),bins,'normalization','probability');
    Accumulated_Prob(:,i) = P';
    end
    heatmap(Accumulated_Prob)
    title('Accumulated Heat Map of RF x position, Vf at x=-1')
    xlabel('d')
    ylabel('x')