MATLAB: How to open csv fille, sort and plot the data from it using GUI

MATLAB

I want to open a result CSV file, sort the rows according to one specific column and also plot a graph of two columns using GUI. I need to open the CSV file from different locations, so I also need to create a browse button also. How can I do it?
Thank you for your time and consideration.

Best Answer

Given that you want to browse open '.csv' file from different locations using GUI, I would recommend using App Designer in MATLAB. As Stephen suggested you can use "uigetfile" function for this. Considering your requirements, you can follow these steps:
  • Create an App Designer Project and you can browse open any '.csv' file using
[filename, pathname, filterindex] = uigetfile('*.csv');
csvfile = csvread(fullfile(pathname, filename));
  • You can sort this '.csv' file using "sortrows" function, based on any column. Refer Documentation: https://www.mathworks.com/help/matlab/ref/sortrows.html
  • Then plot the required columns using the "plot" function. Refer Documentation: https://www.mathworks.com/help/matlab/ref/plot.html
Refer to the attached example code for more details regarding implementation.