Prompt user to load data file
51 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Nick
le 13 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!