フィルターのクリア

Load multiple files into GUI, in specific order

11 ビュー (過去 30 日間)
Plastic Soul
Plastic Soul 2014 年 5 月 29 日
コメント済み: Plastic Soul 2014 年 5 月 30 日
Hello,
I was wondering, is there a way to load multiple files into MatLab GUI, in the order of their selection? For example, lets say I have files: one.txt, two.txt, three.txt, four.txt. Now, if I say:
[FileNames PathNames]=uigetfile('*.txt', 'Chose files to load:','MultiSelect','on');
FileNames = cellstr(FileNames);
for i=1:length(FileNames)
Path{i} = fullfile(PathNames, FileNames{i});
fileID{i} = fopen(Path{i});
while ~feof(fileID{i})
C = textscan(fileID{i},'\t%f',1000000);
end
fclose(fileID{i});
Then, it will load files by alphabet, so when I plot, I will have on Xaxis: four, one, three, two . Therefore, I always have to rename files as: aone, btwo, cthree, dfour . Is it possible to avoid this and import files in the order of selection (by holding CTRL key)?
P.S. Dont mind if you spot an error in the code, I just gave it for better understanding.
  4 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 5 月 29 日
I was able to select the same set of files and have them appear in a different order in the FileNames variable depending upon how the files were sorted in the uicontrol - alphabetically, by modified date, by size, etc. but not by the order in which the files were selected (by me). So it doesn't matter which order I select them in, it just depends upon the order in which they are listed in the uicontrol.
dpb
dpb 2014 年 5 月 29 日
Yes, that's what the doc says...they're returned "sorted in the order your platform uses". It uses at that time the order as selected in the uicontrol via the sorting as selected in the view (I presume that's how you changed the order?).
But, as noted, there's not any place in the OPENFILENAME structure for the info on order selected to be returned by using a wrapper around a native uicontrol call eschewing the Matlab somewhat emasculated wrapper function.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2014 年 5 月 30 日
If all your files are in the same folder, it's fairly easy. You just use a listbox instead of uigetfile(). By making the selection be a persistent or global variable , and by checking it in the listbox callback to see how it changes with each click , you can use ismember to build up a list of selected items in the order they clicked. Hopefully that's a good enough explanation for you to do it, because I didn't have time to program it up for you.
If they're in different folders, you can still do it with extra case to keep track of which folder each item in your listbox came from but since your current method uses uigetfile() I don't think different folders is the case with you.
  1 件のコメント
Plastic Soul
Plastic Soul 2014 年 5 月 30 日
Hi,
Thanks for answering. I will try using the listbox, but I will certainly need some help. Will let you know once I am on it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by