Reading txt file in GUI
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Image Analyst
2020년 7월 28일
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"
답변 (1개)
Image Analyst
2020년 7월 28일
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
Image Analyst
2020년 7월 29일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!