www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/DisplayImageOfMatrixDataExample.m
%% Display Image of Matrix Data % Create matrix |C|. Display an image of the data in |C|. Add a colorbar to % the graph to show the current colormap. % Copyright 2015 The MathWorks, Inc. C = [0 2 4 6; 8 10 12 14; 16 18 20 22]; image(C) colorbar %% % By default, the |CDataMapping| property for the image is set to % |'direct'| so |image| interprets values in |C| as indices into the % colormap. For example, the bottom right pixel corresponding to the last % element in |C|, 22, uses the 22nd color of the colormap. % % Scale the values to the full range of the current colormap by setting % the |CDataMapping| property to |'scaled'| when creating the image. image(C,'CDataMapping','scaled') colorbar %% % Alternatively, you can use the |imagesc| function to scale the values % instead of using |image(C,'CDataMapping','scaled')|. For example, use % |imagesc(C)|.