How do I initialize a n * m colormap matrix
4 vues (au cours des 30 derniers jours)
I want to set a blank colormap (preferably all white) at the beginning of my code so elements can be added to it later. Previously I used the gray scale so I use:
M = zeros(m,n);
but that doesn't work anymore because the colormap requires the results to have three elements (r,g,b).
Guru le 5 Juil 2013
Hmm, you do realize that colormap is intended to serve as a link between values of a matrix and what color they should appear as when you use image(), right?
So the size of the colormap should always be mx3 where m is the maximum value of your matrix. To set a colormap to be all white:
map = ones(m,3);
If you have a matrix N that you want to see as an image and don't know what m should be:
m = ceil(max(N(:)));
Since m is used as a dimension for map, it must be an integer.
for j = 1:1023
for i = 1:989
N(j,i) = [1,1,1];
This statement is invalid because within a nested for-loop, you are trying to assign a vector "[1,1,1]" to an element in N(j,i). So that's an invalid assignment.