Azzera filtri
Azzera filtri

How to normalize an integer matrix, with center at 0 and range between [-1 1]

1 visualizzazione (ultimi 30 giorni)
Hello, I have a 59x15 matrix, with a range of values from -190 to 540. However most of the values are between 0 and 1. So I tried with the imagesc function and the cmap to represent this matrix. The goal was to see among these smaller values which one was larger than another, but since they are competing with very high values, they all end up having the same color, and I cannot distinguish between them which one is larger than another, although slightly.
How can I normalize the whole matrix so that the values are centered on zero, and with the range of values going from -1 to 1.
From what I've seen, in most cases is asked how to normalize either the columns or just the rows, so I'd appreciate help to normalize the whole matrix, in the range [-1 to 1].
Thank you in advance.

Risposte (1)

Chunru
Chunru il 22 Lug 2022
Modificato: Chunru il 22 Lug 2022
Depending on your data, try some of the following:
x = randi([-190 540], [59, 15]);
subplot(221); imagesc(x); colorbar
subplot(222); imagesc(x); clim([-1 1]); colorbar
x1 = x; subplot(223); idx = abs(x1) > 1; x1(idx)=nan; imagesc(x1); colorbar
x2 = x; subplot(224); x2(:)=max(min(x2(:), 1), -1); imagesc(x2); colorbar

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by