Clear Filters
Clear Filters

MATLAB GUI LOAD ERROR

1 view (last 30 days)
Sophie Lis
Sophie Lis on 7 May 2018
Edited: Walter Roberson on 7 May 2018
I am trying to load a .mat file when I press on the load button but nothing is happening for me.
function varargout = User_Sort(varargin)
% USER_SORT MATLAB code for User_Sort.fig
% USER_SORT, by itself, creates a new USER_SORT or raises the existing
% singleton*.
%
% H = USER_SORT returns the handle to a new USER_SORT or the handle to
% the existing singleton*.
%
% USER_SORT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in USER_SORT.M with the given input arguments.
%
% USER_SORT('Property','Value',...) creates a new USER_SORT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before User_Sort_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to User_Sort_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 User_Sort
% Last Modified by GUIDE v2.5 07-May-2018 13:37:13
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @User_Sort_OpeningFcn, ...
'gui_OutputFcn', @User_Sort_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 User_Sort is made visible.
function User_Sort_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 User_Sort (see VARARGIN)
% Choose default command line output for User_Sort
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes User_Sort wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = User_Sort_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 load.
function load_Callback(hObject, eventdata, handles)
% hObject handle to load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load('Sort.mat');
% --- Executes on button press in avg.
function avg_Callback(hObject, eventdata, handles)
% hObject handle to avg (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in std.
function std_Callback(hObject, eventdata, handles)
% hObject handle to std (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in perc.
function perc_Callback(hObject, eventdata, handles)
% hObject handle to perc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

Answers (1)

Walter Roberson
Walter Roberson on 7 May 2018
The data is loaded into the workspace of the callback function, and is then thrown away when the function returns, same as an local variable. You need to store it somewhere you can reach afterwards.
Unfortunately I do not have the link handy to the FAQ section on the ways you can share variables between callbacks.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!