Load data (.csv or .isf) from any directory to process in Matlab Standalone Application (App Designer)
6 views (last 30 days)
I have .csv file to be processed and plot the figure(x,y). I run the app in standalone application and insert the data file. It can process data that is located on Desktop only (that means it can process data which are in same directory with App shortcut).
I want that my app should be able to process .csv data from any directory (any directory from my pc or from removeable disk /usb). I need help. Can anyone please suggest me how to do that ?
Currently I am using following code to load .csv data and plot (x,y).
[filename, path]=uigetfile('*.csv'); %load .csv file
app.DataEditField.Value=filename; %to show the file name is text edit field
B= app.DataEditField.Value %load data in a B
D1= readmatrix(B) %read matrix
x = D1(:,1); %find x
y = D1(:,2); %find y
plot(app.UIAxes,x,y); % Plot (x,y) in UI axes
dpb on 12 Aug 2022
Well, you got the filename and path to it, but you didn't use the path --
You don't have any error handling in the above -- if the user cancels out of uigetfile, the return values for path and filename will be numeric "0" values which are not valid for path for filename and so your app will crash and burn.
See the examples at @doc:uigetfile to see samples of handling the error condition.
I'd suggest you should also probably display the path as well as the file name in your GUI somewhere -- either in the existing text box or add another for the file location if the fully-qualified filename turns out to be too long.