Borrar filtros
Borrar filtros

import data from one gui to another

2 visualizaciones (últimos 30 días)
pawan kumar
pawan kumar el 10 de Oct. de 2011
i have made a gui of unit conversion. i want to use this in another gui for changing units of variable. i want to import data from unit conversion gui to my original gui. is it possible to do so. if yes then how can i implement in.

Respuestas (2)

Daniel Shub
Daniel Shub el 10 de Oct. de 2011
You need to pass the data between the guis with callbacks. There are a number of ways of doing this. Check the FAQ:
  2 comentarios
pawan kumar
pawan kumar el 10 de Oct. de 2011
suppose i give input velocity 200 m/s in my main gui and i want to convert it in ft/sec using conversion gui(operated by a push button in main gui using run command ).i want that this input automatically goes to input of unitconversion gui and after selecting desired unit whatever be the output .this output comes in place on input in main gui programe
please wite the callback code also with your answer
thanks
Daniel Shub
Daniel Shub el 10 de Oct. de 2011
You haven't really provided enough information to write the callback. Even if you did provide more information, I am not going to write a callback function for you. If you have a question about the concept of callbacks, ask that. If you have a specific question about how to implement a callback ask that. In general, don't ask for code.

Iniciar sesión para comentar.


Iman Alsharkawi
Iman Alsharkawi el 10 de Oct. de 2011
In the main gui, make a function callback similar to the one below:
function [] = getscale(varargin)
scale = conversion_gui %where conversion_gui is the name of your function for your other gui
Then in the new gui, conversion_gui, set up how you want your gui to work, buttons and whatnot, then add callbacks similar to the following:
function [conv_value] = conversion_gui(varargin)
%enter all your uicontrols here...
handles.conversion_gui_window = ...
figure(...)
%...
%...
uiwait(handles.conversion_gui_window)
if isappdata(0,'ListConvAppData')
getval = getappdata(0,'ListConvAppData');
conv_value = getval;
rmappdata(0,'ListConvAppData')
else
% figure was deleted
conv_value = 0;
end
%--------------------------------------------------------------------------
%%OK callback
function OKcb(varargin)
if (~isappdata(0, 'ListConvAppData'))
conv_value = get(gcf,'userdata');
setappdata(0,'ListConvAppData',conv_value);
delete(gcbf);
end
%%Cancel callback
function cancelcb(varargin)
hwinedit = varargin{3};
conv_value= 0;
setappdata(0,'ListConvAppData',conv_value)
delete(gcbf);
Keep in mind that this particular code closes the conversion_gui window when the user hits the ok or cancel button (if you have one). You can modify the code however you want and use the setappdata, getappdata, rmappdata functions in Matlab to pass values from one gui to another. Also, I'm just saving the value in the 'userdata' for your figure window. You can save it anywhere and just call that location for your values.
Hope this helps!

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by