I was recently looking at the imagesc function on:
What I want to do is take a square matrix of anything, doesn't matter what, integers, characters etc. and produce an image of it so that I can draw over the top of it i.e. so it produces an image like this:
Can the imagesc function do this? Because trying it so far, I have only been able to get multicoloured squares?
Edit: I tried:
a = ['a','b','c';'d','e','f';'g','h','i']
and then.
imagesc(a)
But all I got was a blank graph and:
{ Error using image
Error using image
Numeric or logical matrix required for image CData
Error in imagesc (line 19)
hh = image(varargin{1},'CDataMapping','scaled');
解决方案
if you use colormap(gray(256)), before imagesc it will givee you a grayscale image