Prompt user to load data file
51 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew Piccolo
am 13 Apr. 2017
Beantwortet: Nick
am 13 Apr. 2017
I am creating a pop-up menu as part of a final project for one of my courses. One option on this menu will ask the user to load a data file, I'm not sure how to ask a user which file they would like to use. I know how to load data files into arrays, but I don't know how to build a prompt that will ask "which file." Preferably I'd like it to open a file explorer in which you select a file, but I'm not sure if this is possible.
Here is what i have. The prompt to select a file to load into an array would be case 2.
choice = 1;
while choice ~= 11
choice = menu('Statistical Analysis','Set username','Load data file','Clear data','Set output filename','Plot histogram','Plot histogram fit','Plot probability plots','Regression of y on x','Find probability (x or z)','Find x or z','Exit')
switch choice
case 0
close all
case 1
username = input('Please input your username:\n','s')
case 2
x = load('input')
case 11
close all
end
end
0 Kommentare
Akzeptierte Antwort
Nick
am 13 Apr. 2017
Take a look at https://www.mathworks.com/help/matlab/ref/uigetfile.html it might be what you are looking for. You can filter by file type as well so below I look for all csv files and then load the selected file.
%Shows all files with a .csv extension
[FileName,PathName,FilterIndex] = uigetfile('.csv')
C = csvread(FileName)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!