Matlab自定义Table表格颜色

4,562次阅读
2 条评论

共计 2569 个字符,预计需要花费 7 分钟才能阅读完成。

代码实现Matlab GUI中表格不同颜色的设置,根据数据的需求

function varargout = x009(varargin)
% X009 M-file for x009.fig
%      X009, by itself, creates a new X009 or raises the existing
%      singleton*.
%
%      H = X009 returns the handle to a new X009 or the handle to
%      the existing singleton*.
%
%      X009('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in X009.M with the given input arguments.
%
%      X009('Property','Value',...) creates a new X009 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before x009_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to x009_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help x009

% Last Modified by GUIDE v2.5 26-Jun-2010 18:09:11

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @x009_OpeningFcn, ...
                   'gui_OutputFcn',  @x009_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before x009 is made visible.
function x009_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to x009 (see VARARGIN)

% Choose default command line output for x009
handles.output = hObject;
data = rand(6,6);
data = mat2cell(data,ones(1,size(data,1)),ones(1,size(data,2)))
data{1,1}=['','',num2str(data{1,1},'%10.4f'), '
']; data{2,2}=['','',num2str(data{2,2},'%10.4f'), '
']; data{3,3}=['','',num2str(data{3,3},'%10.4f'), '
']; % data{1,1} = ['' num2str(data{1,1},'%10.4f') ''] % data{2,2} = ['' num2str(data{2,2},'%10.4f') ''] % data{3,3} = ['' num2str(data{3,3},'%10.4f') ''] % data{4,4} = ['' num2str(data{4,4},'%10.4f') ''] % data{5,5} = ['' num2str(data{5,5},'%10.4f') ''] % data{6,6} = ['' num2str(data{6,6},'%10.4f') ''] % data{6,3} = ['' num2str(data{6,3},'%10.4f') ''] set(handles.uitable1,'data',data) get(handles.uitable1,'ColumnWidth') % Data inversion procedure ------------------------------------------------- % str  = ['' num2str(rand(1,1),'%16.16f') '']; % tok  = regexp(str,'<.*?><.*?>((\w+).*?)<.*?><.*?>','tokens'); % data = str2num(cell2mat(tok{:})) % -------------------------------------------------------------------------- % str = data{6,6}; % tok  = regexp(str,'<.*?><.*?>((\w+).*?)<.*?><.*?>','tokens'); % Recovery = str2num(cell2mat(tok{:})) % ------------------------------------------------------------------------- guidata(hObject, handles); % UIWAIT makes x009 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = x009_OutputFcn(hObject, eventdata, handles)  % varargout  cell array for returning output args (see VARARGOUT); % hObject    handle to figure % eventdata  reserved - to be defined in a future version of MATLAB % handles    structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
正文完
请博主喝杯咖啡吧!
post-qrcode
 
admin
版权声明:本站原创文章,由 admin 2016-11-17发表,共计2569字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(2 条评论)
验证码
gegey 评论达人 LV.1
2016-11-18 08:55:06 回复

点赞达人来啦!

 Windows  Chrome  中国广东省深圳市联通
    admin 博主
    2016-11-18 10:52:44 回复

    @gegey 顶起来

     Android  Chrome  中国广东省深圳市联通