Mark S
Mark S

Reputation: 31

Uploading multiple .txt files at once on MATLAB GUI

I would like some guidance on how to import multiple .txt files containing data seperated by comma on a MATLAB GUI. Once the files are uploaded, I have a function that will manipulate all the data from each .txt file.

Any help is appreciated.

Upvotes: 0

Views: 276

Answers (2)

informaton
informaton

Reputation: 1482

Try uigetfile to launch a dialog for loading files. Set 'MultiSelect' to 'on' in order to select multiple files at once.

Here's an example call:

[filenames, pathname] = uigetfile({'*.txt; *.csv','Comma separated values';...
           '*.*','All files'},'Select files','MultiSelect','on');

You will need to check if the user actually selected a file or if they canceled.

If I understand your question correctly, you have a GUI already. In this case you just need to add the above call to your designated callback function (i.e. whatever you click to invoke this file load interface).

Upvotes: 0

MosGeo
MosGeo

Reputation: 1878

The easiest way to import multiple files is to:

  • Use the file importer GUI in matlab and generate a script after you
    selected your preferred parameters
  • Generate a script (there is a button to generate a script in the importer)
  • Modify the script with a for loop to load multiple files and save them in a variable (a cell array can handle different sizes of data in each file)

Upvotes: 0

Related Questions