How to send a Matrix from a gui to another gui?

2 visualizaciones (últimos 30 días)
Miguel Reina
Miguel Reina el 19 de Abr. de 2016
Editada: Miguel Reina el 19 de Abr. de 2016
Hello, I have the following problem, in one gui called A I use a push button to save a matrix
% --- 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)
X= uigetfile('.txt');
B
and after the same button opens another gui called B. I need to pass the matrix from A to B, how can i do it ?
Thank you in advance.

Respuesta aceptada

Orion
Orion el 19 de Abr. de 2016
Hi,
you can use the functions getappdata and setappdata.
let say that in your callback you get the matrix MyData.
% --- 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)
X= uigetfile('.txt');
%... some calculation
MyData = rand(4,4);
% In the same callback you open the 2nd GUI
B;
% store MyData in B
Bhandle = findall(0,'Name','B'); % assuming this GUI is really named B.
setappdata(Bhandle ,'MyData',MyData);
Then later, in the callback of GUI B, you can retrieve this data by simply doing :
Bhandle = findall(0,'Name','B');
MyData = getappdata(Bhandle ,'MyData');

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps 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