MATLAB GUI: Load Data and Check for Compatibility
function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
[FileName,FilePath] = uigetfile('.','Select the text file to process','Multiselect','off'); % Get the file path ExPath = fullfile(FilePath, FileName); set(handles,edit1,'string',ExPath); % Write to a text editor for user
if strcmp(ExPath(end-2:end),'txt') % Load data handles.data = load(ExPath); % Make sure it is two columns if size(handles.data,1) == 1 || size(handles.data,2) == 1 delimiterIn = '\t'; headerlinesIn = 0; handles.data = importdata(ExPath,delimiterIn,headerlinesIn); end % Check if it is now two columns if size(handles.data,2) ~= 2 if size(handles.data,1) == 1 || size(handles.data,2) == 1 handles.data = reshape( handles.data, length(handles.data)/2, 2 ); end end else % Load data handles.data = xlsread(ExPath); end
% A few checks: this package works for two variables only if size(handles.data,2) ~= 2 msgbox({'........................................',... '........................................',... 'MhAST works for two variables only!',... 'If more than 2 variables, only the 1st two are used',... '........................................',... '........................................'}); end % A few checks: if negative correlation, some copulas don't work r = corr(handles.data,'type','spearman'); if r(1,2) < 0 msgbox({'........................................',... '........................................',... 'Provided data is negatively correlated',... 'Some copulas fail in this situation, check literature!',... '........................................',... '........................................'}); end
% Update handles structure guidata(hObject, handles);
原文地址: https://www.cveoy.top/t/topic/m31O 著作权归作者所有。请勿转载和采集!