フィルターのクリア

import data from one gui to another

2 ビュー (過去 30 日間)
pawan kumar
pawan kumar 2011 年 10 月 10 日
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.

回答 (2 件)

Daniel Shub
Daniel Shub 2011 年 10 月 10 日
You need to pass the data between the guis with callbacks. There are a number of ways of doing this. Check the FAQ:
  2 件のコメント
pawan kumar
pawan kumar 2011 年 10 月 10 日
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 2011 年 10 月 10 日
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.

サインインしてコメントする。


Iman Alsharkawi
Iman Alsharkawi 2011 年 10 月 10 日
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!

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by