matlab gui sider with edit text

2 次查看(过去 30 天)
Kiran Reddy
Kiran Reddy 2015-11-4
i created a gui with slider and edit text so the i can see the changes simulatneously...i am able to see the updated value in the edit text by changing the position of the slider but i need that updated value in workspace or as ouput of variable with clicking on edit box (without running call back function)and viceverse. finally i need sigle output of both functions so that i can assign this value as input of other function. i need one output so that i can use setappdata function to transfer data between the function
function varargout = slidelast(varargin)
% SLIDELAST MATLAB code for slidelast.fig
% SLIDELAST, by itself, creates a new SLIDELAST or raises the existing
% singleton*.
%
% H = SLIDELAST returns the handle to a new SLIDELAST or the handle to
% the existing singleton*.
%
% SLIDELAST('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SLIDELAST.M with the given input arguments.
%
% SLIDELAST('Property','Value',...) creates a new SLIDELAST or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before slidelast_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to slidelast_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 slidelast
% Last Modified by GUIDE v2.5 03-Nov-2015 22:48:37
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @slidelast_OpeningFcn, ...
'gui_OutputFcn', @slidelast_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 slidelast is made visible.
function slidelast_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 slidelast (see VARARGIN)
% Choose default command line output for slidelast
handles.output = hObject;
handles.sliderListener = addlistener(handles.slider1,'ContinuousValueChange', ...
@(hObject, event) slider1_Callback(...
hObject, eventdata, handles));
%set(handles.edit1, 'String', num2str(get(handles.slider1,'value')));
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes slidelast wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = slidelast_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
e
set(handles.slider1, 'Value', str2num(get(handles.edit1, 'String')))
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
set(handles.edit1, 'String', get(hObject,'Value'));
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
  2 个评论
Jan
Jan 2015-11-4
I do not understand this: "i need that updated value in workspace or as ouput of variable with clicking on edit box (without running call back function)and viceverse"
In which workspace do you need the updated value? Variables do not have an output. What does "with clicking on edit box" mean and why do you assume that any GUI interaction could happen without a callback function? And what exactly is meant by "viceversa" here?
Kiran Reddy
Kiran Reddy 2015-11-5
for example this ui in Labview when ever i enter the figure temparature value in edit box or pressing the arrows ,the updated value is transfered to some other function where some analysis is done and output is displayed in the same i need to transfer the data which is updated either directly entering the value in edit text or using the slider ...either of the functions will be perfomed ....then the value acquired by either of the fuction should be transfered to other callback where analysis is done usually we use setappdata to transfer the data between the callbacks in this case we need create two setappdata commands to transfer the data,,, but how to transfer the data if use two getappdata commands it will create two values as input to that function which is not desirable

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-11-5
You would not usually use setappdata() to transfer data. It is a option, but it is not used much for that purpose, not unless you start getting into large variables. See
  2 个评论
Kiran Reddy
Kiran Reddy 2015-11-5
thanks for the comment ..what ever may be command used to transfer the data... i need updated value in the workspace ...the value can be updated either by editing edit text or moving the slider and that data has to be transfered to other how can i code for this .
Kiran Reddy
Kiran Reddy 2015-11-5
see the simple one with edit text and sider 1.whenever i press the slider the value changes in the edit box 2. i can directly entire the value to the edit box value updated by clicking slider should assigned to something to pass and it is the same for the edit box ....then how to pass the value while value can be updated by anyone of the two as mentioned

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by