MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Metin
0

Error while evaluating uicontrol Callback (GUI_handle problem)

Metin
さんによって質問されました 2013 年 8 月 19 日
最新アクティビティ Ahmed Saeed Mansour さんによって 回答されました 2018 年 5 月 10 日
hi everybody, my problem is about programmed GUI. first I read "mean" and "standard deviation" for a vector from GUI and than create a vector depends on those values to show all values to user to make them editable also. Up to now I have succeed to create the the editable table but the values does not look like as user has initialized, I guess it is because of str2double and num2str conversions, because in the function that I want to make the calculation it gives error of
%%%%%%%%%% ??? Reference to non-existent field 'R_leak_1_mean_value'. Error in ==> GUI_Module>Button_Calculate at 150 h.R_leak_1_value =ones(48,1).*h.R_leak_1_mean_value + randn(48,1).*h.R_leak_1_std_value; ??? Error while evaluating uicontrol Callback %%%%%%%%% here infact when I run simulation step by step in the handle of "h" I can see R_leak_1_mean_value which is a conversed value of string of the same variable but whenever I go another function of where I want to create the array it gives this error. Although I use at the first and last line of each
function
" variables =guidata(h.fig);" and "guidata(h.fig,variables);" respectively I think still I cannot save and call the variable whenever I need I hope I have clearly defined the problem I have given the m-file that I've written for GUI any suggestion will appreciated thanks in advance:)
if true function GUI_module h.fig = figure('units','pixel','OuterPosition',[2 3 750 450],'ToolBar','none','MenuBar','none','Name','Balancing Model','NumberTitle','off'); variables =guidata(h.fig); %% Text boxes h.components_text = uicontrol('style','text','units','normalized','position',[1/20 36/40 0.46 1/20], 'HorizontalAlignment','center','string','Initialization'); h.mean_text = uicontrol('style','text','units','normalized','position',[6/20 33/40 0.1 1/20], 'HorizontalAlignment','center','string','Mean value'); h.std_text = uicontrol('style','text','units','normalized','position',[8.15/20 33/40 0.1 1/20],'HorizontalAlignment','center','string','Std value'); h.R_leak_1_text = uicontrol('style','text','units','normalized','position',[1/20 30/40 0.2 1/20], 'HorizontalAlignment','left', 'string','R_leak_1'); h.R_leak_2_text =uicontrol('style','text','units','normalized','position',[1/20 26/40 0.2 1/20], 'HorizontalAlignment','left', 'string','R_leak_2'); h.R_leak_1_mean=uicontrol('style','edit','string','','units','normalized','position', [ 6/20 30/40 0.1 1/20], 'callback',@R_leak_1_mean); h.R_leak_1_std=uicontrol('style','edit','string','','units','normalized','position', [ 8.15/20 30/40 0.1 1/20],'callback',@R_leak_1_std); h.R_leak_2_mean=uicontrol('style','edit','string','','units','normalized','position', [ 6/20 26/40 0.1 1/20], 'callback',@R_leak_2_mean); h.R_leak_2_std = uicontrol('style','edit','string','','units','normalized','position', [ 8.15/20 26/40 0.1 1/20],'callback',@R_leak_2_std); %% Button h.ButtonCalculate = uicontrol('style','pushbutton','string','Calculete values','units','normalized','position', [15/20 2/40 0.15 1/20]); %% Callbacks set(h.R_leak_1_mean,'callback',{@R_leak_1_mean,h}); set(h.R_leak_1_std,'callback',{@R_leak_1_std,h}); set(h.R_leak_2_mean,'callback',{@R_leak_2_mean,h}); set(h.R_leak_2_std,'callback',{@R_leak_2_std,h}); function R_leak_1_mean(hobject,event,h) variables =guidata(h.fig); h=read_inputs(h); guidata(h.fig,variables); end function R_leak_1_std(hobject,event,h) variables =guidata(h.fig); h=read_inputs(h); guidata(h.fig,variables); end function R_leak_2_mean(hobject,event,h) variables =guidata(h.fig); h=read_inputs(h); guidata(h.fig,variables); end function R_leak_2_std(hobject,event,h) variables=guidata(h.fig) h=read_inputs(h); guidata(h.fig,variables); end function [h]=Button_Calculate(hObject,eventdata,h) variables =guidata(h.fig); h.R_leak_1_value =h.R_leak_1_mean_value + randn(48,1).*h.R_leak_1_std_value; h.R_leak_2_value =h.R_leak_2_mean_value + randn(48,1).*h.R_leak_2_std_value; h.fig_2 =figure('units','pixel','OuterPosition',[-3 -3 750 450],'ToolBar','none','MenuBar','none','Name','Circuit Parameters','NumberTitle','off'); edit_table =[true true]; h.table =uitable('units','normalized','position',[2/40 2/40 30/40 34/40],'ColumnWidth','auto','ColumnEditable', edit_table); cnames ={'R_leak_1','R_leak_2'}; rnames ={'Cell_1','Cell_2','Cell_3','Cell_4','Cell_5','Cell_6','Cell_7','Cell_8'}; set(h.R_leak_1,'string',num2str(h.R_leak_1_value)); set(h.R_leak_2,'string',num2str(h.R_leak_2_value)); h.my_data =zeros(8,2); h.my_data(:,1) =h.R_leak_1; h.my_data(:,2) =h.R_leak_2; set(h.table,'Data',h.my_data,'Columnname',cnames, 'Rowname', rnames); h.Button_simulate = uicontrol('style','pushbutton','string','Run simulation','units','normalized','position', [17/20 4/40 0.1 1/20]); set(h.ButtonSimulate,'callback',{@Button_Simulate,h}); guidata(h.fig,variables); end function [h]=Button_Simulate(hObject,eventdata,h) variables =guidata(h.fig); assignin('base','R_leak_1',h.R_leak_1_value); assignin('base','R_leak_2',h.R_leak_2_value); guidata(h.fig,variables); end function [h]=read_inputs(h) variables =guidata(h.fig); h.R_leak_1_mean_value =str2double(get(h.R_leak_1_mean,'String')); h.R_leak_1_std_value =str2double(get(h.R_leak_1_std,'String')); h.R_leak_2_mean_value =str2double(get(h.R_leak_2_mean,'String')); h.R_leak_2_std_value =str2double(get(h.R_leak_2_std,'String')); guidata(h.fig,variables); end end end %%%%%%%%%%%%%%%

  0 件のコメント

サインイン to comment.

2 件の回答

回答者: Jan
2013 年 8 月 20 日
 採用された回答

The code you posted is incomprehensibly formatted.
However, my guess is, that you did a function call, that changes the handle, but didn't update your handles structure after that.
i.e.
function change_handle( hObject, eventdata, handles )
handles.value_A = 5;
guidata( hObject, handles );
function caller_function( hObject, eventdata, handles )
handles = guidata( hObject, handles );
change_handle( hObject, evendata, handles );
% uncomment the following line, to prevent your error
% handles = guidata( hObject );
% if line above is commented, the following will crash
set( handles.text_field, 'String', num2str( handles.value_A ) );
What happens is, that the function change_handles is called in the caller_function and the field handles.value_A is created. The caller_function then wants to access this field. If the handles structure is not updated, the field is simply non-existant in allthough you called guidata() in the change_handles function.

  3 件のコメント

Metin
2013 年 8 月 20 日
if true
function GUI_Module
close all
clc
h.fig = figure('units','pixel','OuterPosition',[2 3 750 450],'ToolBar','none','MenuBar','none','Name','Balancing Model','NumberTitle','off');
%%Text boxes
h.components_text = uicontrol('style','text','units','normalized','position',[1/20 36/40 0.46 1/20], 'HorizontalAlignment','center','string','Initialization');
h.mean_text = uicontrol('style','text','units','normalized','position',[6/20 33/40 0.1 1/20], 'HorizontalAlignment','center','string','Mean value');
h.std_text = uicontrol('style','text','units','normalized','position',[8.15/20 33/40 0.1 1/20],'HorizontalAlignment','center','string','Std value');
h.R_leak_1_text = uicontrol('style','text','units','normalized','position',[1/20 30/40 0.2 1/20], 'HorizontalAlignment','left', 'string','R_leak_1');
h.R_leak_2_text = uicontrol('style','text','units','normalized','position',[1/20 26/40 0.2 1/20], 'HorizontalAlignment','left', 'string','R_leak_2');
h.R_inner_text = uicontrol('style','text','units','normalized','position',[1/20 22/40 0.2 1/20], 'HorizontalAlignment','left', 'string','R_inner');
h.Capacitors_text = uicontrol('style','text','units','normalized','position',[1/20 18/40 0.2 1/20], 'HorizontalAlignment','left', 'string','Capacitors');
h.circuit_text = uicontrol('style','text','units','normalized','position',[1/20 14/40 0.2 1/20], 'HorizontalAlignment','left', 'string','Initial capacitor voltage');
h.max_min_text = uicontrol('style','text','units','normalized','position',[1/20 10/40 0.2 1/20], 'HorizontalAlignment','left', 'string','Module voltages (min&max)');
h.simulation_text = uicontrol('style','text','units','normalized','position',[1/20 6/40 0.2 1/20], 'HorizontalAlignment','left', 'string','"step" and "end" times');
h.quant_eta_text = uicontrol('style','text','units','normalized','position',[1/20 2/40 0.2 1/20], 'HorizontalAlignment','left', 'string','"efficiency" and "quantization" ');
%%Editboxes
h.R_leak_1_mean = uicontrol('style','edit','string','','units','normalized','position', [ 6/20 30/40 0.1 1/20], 'callback',@R_leak_1_mean);
h.R_leak_1_std = uicontrol('style','edit','string','','units','normalized','position', [ 8.15/20 30/40 0.1 1/20],'callback',@R_leak_1_std);
h.R_leak_2_mean = uicontrol('style','edit','string','','units','normalized','position', [ 6/20 26/40 0.1 1/20], 'callback',@R_leak_2_mean);
h.R_leak_2_std = uicontrol('style','edit','string','','units','normalized','position', [ 8.15/20 26/40 0.1 1/20],'callback',@R_leak_2_std);
h.R_inner_mean = uicontrol('style','edit','string','','units','normalized','Position', [ 6/20 22/40 0.1 1/20], 'callback',@R_inner_mean);
h.R_inner_std = uicontrol('style','edit','string','','units','normalized','Position', [ 8.15/20 22/40 0.1 1/20],'callback',@R_inner_std);
h.Cap_mean = uicontrol('style','edit','string','','units','normalized','Position', [ 6/20 18/40 0.1 1/20], 'callback',@Cap_mean);
h.Cap_std = uicontrol('style','edit','string','','units','normalized','Position', [ 8.15/20 18/40 0.1 1/20],'callback',@Cap_std);
h.U_init_mean = uicontrol('style','edit','string','','units','normalized','Position', [ 6/20 14/40 0.1 1/20], 'callback',@U_init_mean);
h.U_init_std = uicontrol('style','edit','string','','units','normalized','Position', [ 8.15/20 14/40 0.1 1/20],'callback',@U_init_std);
h.U_max_set = uicontrol('style','edit','string','','units','normalized','Position', [ 6/20 10/40 0.1 1/20], 'callback',@U_max_set);
h.U_min_set = uicontrol('style','edit','string','','units','normalized','Position', [ 8.15/20 10/40 0.1 1/20],'callback',@U_min_set);
h.t_step = uicontrol('style','edit','string','','units','normalized','Position', [ 6/20 6/40 0.1 1/20], 'callback',@t_step);
h.t_end = uicontrol('style','edit','string','','units','normalized','Position', [ 8.15/20 6/40 0.1 1/20],'callback',@t_end);
h.eta = uicontrol('style','edit','string','','units','normalized','Position', [ 6/20 2/40 0.1 1/20], 'callback',@eta);
h.quant = uicontrol('style','edit','string','','units','normalized','Position', [ 8.15/20 2/40 0.1 1/20],'callback',@quant);
%%Button
h.ButtonCalculate = uicontrol('style','pushbutton','string','Calculete values','units','normalized','position', [15/20 2/40 0.15 1/20]);
%%functions for each edit boxes R_leak_1 calculation
function R_leak_1_mean(hObject,eventdata,h)
variable=guidata(h.fig);
h.R_leak_1_mean_value =str2double(get(h.R_leak_1_mean,'String'));
guidata(h.fig,variable);
end
function R_leak_1_std(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
%%R_leak_2 calculation
function R_leak_2_mean(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function R_leak_2_std(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
%%functions for each edit boxes R_inner calculation
function R_inner_mean(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function R_inner_std(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
%%functions for each edit boxes CAPACITENCE calculation
function Cap_mean(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function Cap_std(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
%%functions for each edit boxes U_INITIAL calculation
function U_init_mean(varargin)
varargin=guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function U_init_std(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
%%functions for simulation parameters
function U_max_set(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function U_min_set(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function t_step(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function t_end(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function eta(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
function quant(varargin)
varargin =guidata(h.fig);
h=read_inputs(h);
guidata(h.fig,varargin);
end
%%Fuction of Calculate & edit values Button
function ButtonCalculate(hObject,eventdata,h)
variable =guidata(h.fig);
h.R_leak_1_value =h.R_leak_1_mean_value + randn(48,1).*h.R_leak_1_std_value;
h.R_leak_2_value =h.R_leak_2_mean_value + randn(48,1).*h.R_leak_2_std_value;
h.R_inner_value =h.R_inner_mean_value + h.R_inner_std_value.*randn(48,1);
h.Cap_value =h.Cap_mean_value + randn(48,1).*h.Cap_std_value;
h.U_init_value =h.U_init_mean_value + randn(48,1).*h.U_init_std_value;
h.fig_2 =figure('units','pixel','OuterPosition',[-3 -3 750 450],'ToolBar','none','MenuBar','none','Name','Circuit Parameters','NumberTitle','off');
edit_table =[true true true true true];
h.table =uitable('units','normalized','position',[2/40 2/40 30/40 34/40],'ColumnWidth','auto','ColumnEditable', edit_table);
cnames ={'R_leak_1','R_leak_2','R_inner','Capacitences','U_initial'};
rnames ={'Cell_1','Cell_2','Cell_3','Cell_4','Cell_5','Cell_6','Cell_7','Cell_8','Cell_9','Cell_10','Cell_11','Cell_12','Cell_13','Cell_14','Cell_15','Cell_16','Cell_17','Cell_18','Cell_19','Cell_20','Cell_21','Cell_22','Cell_23','Cell_24','Cell_25','Cell_26','Cell_27','Cell_28','Cell_29','Cell_30','Cell_31','Cell_32','Cell_33','Cell_34','Cell_35','Cell_36','Cell_37','Cell_38','Cell_39','Cell_40','Cell_41','Cell_42','Cell_43','Cell_44','Cell_45','Cell_46','Cell_47','Cell_48'};
set(h.R_leak_1,'string',num2str(h.R_leak_1_value));
set(h.R_leak_2,'string',num2str(h.R_leak_2_value));
set(h.R_inner,'string',num2str(h.R_inner_value));
set(h.Cap,'string',num2str(h.Cap_value));
set(h.U_init,'string',num2str(h.U_init_value));
h.my_data =zeros(48,5);
h.my_data(:,1) =h.R_leak_1;
h.my_data(:,2) =h.R_leak_2;
h.my_data(:,3) =h.R_inner;
h.my_data(:,4) =h.Cap;
h.my_data(:,5) =h.U_init;
set(h.table,'Data',h.my_data,'Columnname',cnames, 'Rowname', rnames);
h.Button_simulate = uicontrol('style','pushbutton','string','Run simulation','units','normalized','position', [17/20 4/40 0.1 1/20]);
set(h.ButtonSimulate,'callback',{@Button_Simulate,h});
guidata(h.fig,variable);
end
%%Run_simulation Button
function [h]=Button_Simulate(varargin)
%varargin =guidata(h.fig);
assignin('base','R_leak_1',h.R_leak_1_value);
assignin('base','R_leak_2',h.R_leak_2_value);
assignin('base','R_inner',h.R_inner_value);
assignin('base','Cap',h.Cap_value);
assignin('base','U_init',h.U_init_value);
assignin('base','U_max_set',h.U_max_set_value);
assignin('base','U_min_set',h.U_min_set_value);
assignin('base','t_step',h.t_step_value);
assignin('base','t_end',h.t_end_value);
assignin('base','eta',h.eta_value);
assignin('base','quant',h.quant_value);
guidata(h.fig,variables);
open('super_capacitor_balance_2008a');
%sim('super_capacitor_balance_2008a');
end
%%Read functions
function [h]=read_inputs(h)
% variables =guidata(h.fig);
h.R_leak_1_mean_value =str2double(get(h.R_leak_1_mean,'String'));
h.R_leak_1_std_value =str2double(get(h.R_leak_1_std,'String'));
h.R_leak_2_mean_value =str2double(get(h.R_leak_2_mean,'String'));
h.R_leak_2_std_value =str2double(get(h.R_leak_2_std,'String'));
h.R_inner_mean_value =str2double(get(h.R_inner_mean,'String'));
h.R_inner_std_value =str2double(get(h.R_inner_std,'String'));
h.Cap_mean_value =str2double(get(h.Cap_mean,'String'));
h.Cap_std_value =str2double(get(h.Cap_std,'String'));
h.U_init_mean_value =str2double(get(h.U_init_mean,'String'));
h.U_init_std_value =str2double(get(h.U_init_std,'String'));
h.U_max_set_value =str2double(get(h.U_max_set,'String'));
h.U_min_set_value =str2double(get(h.U_min_set,'String'));
h.t_step_value =str2double(get(h.t_step,'String'));
h.t_end_value =str2double(get(h.t_end,'String'));
h.eta_value =str2double(get(h.eta,'String'));
h.quant_value =str2double(get(h.quant,'String'));
%guidata(h.fig,variables);
end
%%Callbacks
set(h.R_leak_1_mean,'callback',{@R_leak_1_mean,h});
set(h.R_leak_1_std,'callback',{@R_leak_1_std,h});
set(h.R_leak_2_mean,'callback',{@R_leak_2_mean,h});
set(h.R_leak_2_std,'callback',{@R_leak_2_std,h});
set(h.R_inner_mean,'callback',{@R_inner_mean,h});
set(h.R_inner_std,'callback',{@R_inner_std,h});
set(h.Cap_mean,'callback',{@Cap_mean,h});
set(h.Cap_std,'callback',{@Cap_std,h});
set(h.U_init_mean,'callback',{@U_init_mean,h});
set(h.U_init_std,'callback',{@U_init_std,h});
set(h.U_max_set,'callback',{@U_max_set,h});
set(h.U_min_set,'callback',{@U_min_set,h});
set(h.t_step,'callback',{@t_step,h});
set(h.t_end,'callback',{@t_end,h});
set(h.ButtonCalculate,'callback',{@ButtonCalculate,h});
end
%%%%%%%%%I hope this comprehensive thanks for your answer but I couldn't %%%mange to solve end
Metin
2013 年 8 月 20 日
Hi Jan, you are right about to define the problem, but normally when I have to use calling variables with
variable=guidata(hObject)
and also to store the variable in the handle
guidata(hObject,variables)
after I write callback function of each edit box, the variable inside has to be saved in the handle up to change or erase edit box but why I couldn't manage to reach the variable when called even I stored it before, uncomment the line that you have mentioned results in other error of:
if true
??? Error while evaluating uicontrol Callback
??? Undefined function or variable 'variable'.
end
so it seems there has to be another way or do I have to change all the program structure? any comment please
thanks
Jan
2013 年 8 月 21 日
Are you using GUIDE to develop your GUI? If not taking a good look at a GUIDE generated GUI may be a good idea - if only to see how a clean structure can be accomplished.

サインイン to comment.


回答者: Ahmed Saeed Mansour 2018 年 5 月 10 日

Hello, I have a problem, I cannot run the code due to the following error: Reference to non-existent field 'current_data'.
Error in untitled1>pushbutton5_Callback (line 102) mesh(handles.current_data);
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in untitled1 (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)untitled1('pushbutton5_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
>> and the code is
function varargout = untitled1(varargin) % UNTITLED1 MATLAB code for untitled1.fig % UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing % singleton*. % % H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to % the existing singleton*. % % UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in UNTITLED1.M with the given input arguments. % % UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before untitled1_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to untitled1_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 untitled1
% Last Modified by GUIDE v2.5 10-May-2018 17:53:10
% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @untitled1_OpeningFcn, ... 'gui_OutputFcn', @untitled1_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
% Create the data to plot. handles.peaks=peaks(35); handles.membrane=membrane; [x,y] = meshgrid(-8:.5:8); r = sqrt(x.^2+y.^2) + eps; sinc = sin(r)./r; handles.sinc = sinc; % Set the current data value. handles.current_data = handles.peaks; surf(handles.current_data)
% --- Executes just before untitled1 is made visible. function untitled1_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 untitled1 (see VARARGIN)
% Choose default command line output for untitled1 handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes untitled1 wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = untitled1_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;
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Display contour plot of the currently selected data. contour(handles.current_data);
% --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Display mesh plot of the currently selected data. mesh(handles.current_data);
% --- Executes on button press in pushbutton6. function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Display surf plot of the currently selected data. surf(handles.current_data);
% --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1 % Determine the selected data set. str = get(hObject, 'String'); val = get(hObject,'Value'); % Set current data to the selected data set. switch str{val}; case 'peaks' % User selects peaks. handles.current_data = handles.peaks; case 'membrane' % User selects membrane. handles.current_data = handles.membrane; case 'sinc' % User selects sinc. handles.current_data = handles.sinc; end % Save the handles structure. guidata(hObject,handles)
% --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
what should I do? Thanks

  0 件のコメント

サインイン to comment.



Translated by