function csvPlotterGUI
mainFig = figure( ...
'Name', 'CSV Plotter', ...
'NumberTitle', 'off', ...
'Position', [100, 100, 800, 400], ...
'ResizeFcn', @resizeCallback, ...
'Visible','off');
set(mainFig,'Visible','on');
end
mainFig = figure('Name', 'CSV Plotter', 'NumberTitle', 'off', 'Position', [100, 100, 800, 400],'ResizeFcn', @resizeCallback,'Visible','off');
fileButton = uicontrol('Style', 'pushbutton', 'String', 'Select CSV File', 'Callback', @selectFileCallback);
fileText = uicontrol('Style', 'text', 'String', 'Selected File:');
fileDisplay = uicontrol('Style', 'text');
xText = uicontrol('Style', 'text', 'String', 'Select X Variable:');
xPopup = uicontrol('Style', 'popupmenu');
yText = uicontrol('Style', 'text', 'String', 'Select Y Variable:');
yPopup = uicontrol('Style', 'popupmenu');
plotButton = uicontrol('Style', 'pushbutton', 'String', 'Plot', 'Callback', @plotCallback);
dataTable = uitable('ColumnName', {}, 'ColumnWidth', {175});
set(mainFig,'Visible','on')
figPosition = get(mainFig, 'Position');
set(fileButton, 'Position', [20, figPosition(4) - 50, buttonWidth, buttonHeight]);
set(fileText, 'Position', [150, figPosition(4) - 45, textWidth, textHeight]);
set(fileDisplay, 'Position', [350, figPosition(4) - 45, textWidth, textHeight]);
set(xText, 'Position', [20, figPosition(4) - 100, textWidth, textHeight]);
set(xPopup, 'Position', [150, figPosition(4) - 100, buttonWidth, buttonHeight]);
set(yText, 'Position', [20, figPosition(4) - 150, textWidth, textHeight]);
set(yPopup, 'Position', [150, figPosition(4) - 150, buttonWidth, buttonHeight]);
set(plotButton, 'Position', [20, figPosition(4) - 200, buttonWidth, buttonHeight]);
set(dataTable, 'Position', [500, 50, figPosition(3) - 520, figPosition(4) - 100]);
function resizeCallback(~, ~)
function selectFileCallback(~, ~)
[filename, path] = uigetfile('*.csv', 'Select CSV File');
selectedFile = fullfile(path, filename);
set(fileDisplay, 'String', selectedFile);
data = readtable(selectedFile);
variables = data.Properties.VariableNames;
set(xPopup, 'String', variables);
set(yPopup, 'String', variables);
function updateDataTable()
set(dataTable, 'Data', table2cell(data), 'ColumnName', data.Properties.VariableNames);
function plotCallback(~, ~)
if isempty(selectedFile) || strcmp(selectedFile, 'Selected File:')
errordlg('Please select a CSV file first.', 'Error');
xVarIndex = get(xPopup, 'Value');
yVarIndex = get(yPopup, 'Value');
xData = data.(data.Properties.VariableNames{xVarIndex});
yData = data.(data.Properties.VariableNames{yVarIndex});
plot(xData, yData, 'o-');
xlabel(data.Properties.VariableNames{xVarIndex});
ylabel(data.Properties.VariableNames{yVarIndex});