Reading txt file in GUI
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi there. I was wondering whether is possible to read a specific *.txt file that is composed from selecting different values from the matlab app designer dropdown menus, BUT, skipping the dialogue box. So I pick, e.g., file 'E1S1T1.txt' and then plot content then select E2 from the dropdown menu and the file is "E2S1T1.txt' and so on. When I checked and open the file using dlmread( strcat(pwd,'\','E',num2str(s),'S,num2str(s),'T',num2str(t),'.txt')) and it all seems fine, but cannot incoporate to the GUI. Any suggestions please to solve this prob.
cheers
Eduardo
3 Kommentare
Image Analyst
am 28 Jul. 2020
Maria, can you tranfer your answer down to the official "Answers" section with the other answers, instead of up here in the comments which is used to ask posters for clarification of the question? You can also get credit for it down there in terms of "reputation points"
Antworten (1)
Image Analyst
am 28 Jul. 2020
If your drop down lists have numbers in them, and are named E, S, and T, then create a filename like this:
eValue = app.E.Value;
sValue = app.S.Value;
tValue = app.T.Value;
baseFileName = sprintf('E%dS%dT%d.txt', eValue, sValue, tValue);
fullFileName = fullfile(folder, baseFileName); % Folder is where the files live.
if ~isfile(fullFileName)
warningMessage = sprintf('Warning: file does not exist:\n%s', fullFileName);
fprintf('%s\n', warningMessage);
uiwait(errordlg(warningMessage));
return;
end
% else read in that file and do something with it.
2 Kommentare
Image Analyst
am 29 Jul. 2020
I'm not using App Designer yet but if it's like GUIDE, the value property will be the index (1,2,3,...) of what item was selected, not the actual text of the item. You can get the String property to get all teh strings in the drop down list, then use the index to get the text, if you want/need it
index = app.Group.Value; %
allItems = app.Group.String; % MS and HC or whatever.
selectedText = allItems{index}; % 'MS' if that was selected or 'HC' if the second item was selected
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps 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!