% --- FIGURE -------------------------------------
handles.figure1 = figure( ...
  'Tag', 'figure1', ...
  'Units', 'characters', ...    
  'Position', [102.8 24.2307692307692 126.8 33], ...
  'Name', 'Parameter', ...
  'MenuBar', 'figure', ...
  'NumberTitle', 'off', ...
  'Color', [0.941 0.941 0.941]);
  % --- UITABLE -------------------------------------
  % Initialize empty string for components of the Data
Data = repmat({''},16,5);
  
uitable1 = uitable( ...
    'CellSelectionCallback', @uitable1_CellSelectionCallback,...
    'Parent', handles.figure1, ...
    'Tag', 'uitable1', ...
    'UserData', zeros(1,0), ...
    'Units', 'characters', ...
    'Position', [12.2 8 85.6 21], ...
    'BackgroundColor', [1 1 1;0.961 0.961 0.961], ...
    'ColumnEditable', [true,true,true,true,true], ...
    'ColumnFormat', {'char','char','char','char','char'}, ...
    'ColumnName',{'ID','<html>P<sub>i</sub> -stationary<br>[W]','<html>P<sub>i</sub> -transient<br>[W/t]','<html>&Omega','V'}, ... % '<html>P<sub>i</sup></html>[W]'für griechische Buchstaben in einer Column <HTML>&Buchstabe
    'ColumnWidth', {'auto','auto','auto','auto','auto'}, ...
    'Data',Data); % add the "string" Data
    

function uitable1_CellSelectionCallback(hObject, eventdata)



datatable_row = eventdata.Indices(1);
datatable_col = eventdata.Indices(2);

% Accept clicks on 3rd columns only:
if datatable_col ~= 3
  return;
end



Columndata = get(hObject,'Data');


[FileName,PathName] = uigetfile({'*.txt'; '*.csv'},'Select the configuration');

fidi = fopen( FileName );
data = textscan(fidi, '%f%f', 'Delimiter',',');

if strcmp(Columndata(1,1),'User Defined')
FilePath = fullfile(PathName,FileName);
if isequal(FileName,0)
return
end
[pathstr, name, ext] = fileparts(FilePath);
ParameterList{end+1} = name;
set(uitable1,'ColumnFormat',{ParameterList});

end
end




%     'CellSelectionCallback',{@cell_select_callback handles.figure1});
% function output = mycellselection(~,event)
% 
% if isempty(event.Indixes)
%     output = [];
%     return
% end
% % rest of your code for cell selection
% 
% end
%%Test einlesen einer .csv-,.txt-Datein




% function uitable1_CellSelectionCallback(hObject, eventdata, handles)
% % hObject    handle to uitable1 (see GCBO)
% % eventdata  structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% %	Indices: row and column indices of the cell(s) currently selecteds
% % handles    structure with handles and user data (see GUIDATA)
% 
% %handles=guidata(source);
% handles.currentCell=eventdata.Indices;
% guidata(gcf,handles);
% if ~isempty(eventdata.Indices)&&~isempty(data)
%     handles.currentCell=eventdata.Indices;
%     guidata(hObject,handles);
%     Indices=handles.currentCell;
%     data=get(handles.uitable1,'Data');
%     data=data(Indices(1),Indices(2));
%     set(handles.editNum,'String', data);
%  end
% Indices=handles.currentCell;
% data=get(handles.uitable1,'Data');
% data=data(Indices(1),Indices(2));
% set(handles.editNum,'String', data);
% 
% end




% function data_uitable1_CellSelectionCallback(hObject, eventdata, handles)
% % hObject    handle to data_uitable (see GCBO)
% % eventdata  structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% %	Indices: row and column indices of the cell(s) currently selecteds
% % handles    structure with handles and user data (see GUIDATA)
% % disp(eventdata)
% for i = 1:size(Data,1)
%       
% end
% 
% handles.datatable_row = eventdata.Indices(i);
% handles.datatable_col = eventdata.Indices(4);
% guidata(hObject, handles);
% 
% end
 

%[FileName,PathName] = uigetfile({'*.txt'; '*.csv'},'Select the configuration');




