이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to show the contents of a folder in app designer and plot the files in it ?
조회 수: 5 (최근 30일)
이전 댓글 표시
farzad
2020년 3월 26일
Hi All
my code generates some excel files as output in a certain folder. which are a 2 column data. I was wondering if there is any way to show the content of this folder in a box as a list that dynamically updates as the code proceeds, or even just using a button that can update this box. then by hovering over each file name and selecting it from the box, I could plot it in a UIfigure plot in the app window. is this possible ?
채택된 답변
Ameer Hamza
2020년 3월 26일
See the attached app. It will list all the .xlsx file in the current folder and if it only has two columns, then plot it on the axes.
댓글 수: 17
Ameer Hamza
2020년 3월 26일
App designer was introduced in R2016a. Hopefully, it can be opened in R2017b.
farzad
2020년 3월 26일
It didn't open with the 2017b, so maybe you saved it with a newer version despite it was done in 2016 versin. maybe you could just copy the whole in an m file or txt ?
Ameer Hamza
2020년 3월 26일
I used the app designer to save a version compatible with R2017b. I think the file attached to this comment should work.
Ameer Hamza
2020년 3월 26일
Also I forgot to change a line in this code which is compatible with R2017b. Please replace the readmatrix line in the code view with the following line
data = xlsread(filename);
farzad
2020년 3월 26일
thank you so much !! it works perfectly ! just that I was trying to include the hold on button in my case, so that when I move from one file to the other one, if I have checked the hold on check button, it holds the previous figure
I did the follwing but it did not work
% Value changed function: HoldPlotsCheckBox
function HoldPlotsCheckBoxValueChanged(app, event)
value = app.HoldPlotsCheckBox.Value;
end
% Value changed function: FilesListBox
function FilesListBoxValueChanged(app, event)
switch app.HoldPlotsCheckBox.Value
case 0
app.selectplot= uigetfile();
drawnow;
% FocusUIFigure(app.UIFigure)
app.UIFigure.Visible = 'off';
app.UIFigure.Visible = 'on';
filename = app.FilesListBox.Value;
data = xlsread(filename);
plot(app.UIAxes, data(:,1), data(:,2));
case 1
app.selectplot= uigetfile();
drawnow;
% FocusUIFigure(app.UIFigure)
app.UIFigure.Visible = 'off';
app.UIFigure.Visible = 'on';
filename = app.FilesListBox.Value;
data = xlsread(filename);
plot(app.UIAxes, data(:,1), data(:,2));
hold on
end
end
farzad
2020년 3월 26일
thank you , but I tried it and when I press down the Hold button, only the first graph is plotted and then if I click on the next files, nothing happnes untill I unpress the Hold
farzad
2020년 3월 26일
and by the way I edited my code, it can only hold 2 plots, but also in a strange manner :
% Value changed function: HoldPlotsCheckBox
function HoldPlotsCheckBoxValueChanged(app, event)
value = app.HoldPlotsCheckBox.Value;
end
% Value changed function: FilesListBox
function FilesListBoxValueChanged(app, event)
switch app.HoldPlotsCheckBox.Value
case 0
cla(app.UIAxes)
drawnow;
% FocusUIFigure(app.UIFigure)
% app.UIFigure.Visible = 'off';
% app.UIFigure.Visible = 'on';
filename = app.FilesListBox.Value;
data = xlsread(filename);
plot(app.UIAxes, data(:,1), data(:,2));
case 1
drawnow;
% FocusUIFigure(app.UIFigure)
% app.UIFigure.Visible = 'off';
% app.UIFigure.Visible = 'on';
filename = app.FilesListBox.Value;
data = xlsread(filename);
plot(app.UIAxes, data(:,1), data(:,2));
hold(app.UIAxes);
end
farzad
2020년 3월 26일
and one really more important question : How do I add a legend while I am holding the plots ??
Ameer Hamza
2020년 3월 27일
"when I press down the Hold button, only the first graph is plotted and then if I click on the next files, nothing happnes untill I unpress the Hold"
Isn't it the required behaviour as you previously mentioned "I was trying to include the hold on button in my case, so that when I move from one file to the other one, if I have checked the hold on check button, it holds the previous figure"
Also coping the code is not helpful to check the issue with app designer. You can attached the .mlapp file so that i can directly open it in my PC.
For adding legend, please check the attached file.
farzad
2020년 3월 27일
about plotting : the required was: when I press the hold, the app overlays the next plots on the first one, so I can compare them.
about the legend, I tried it. it does not work in the way I mentioned: it only writes one single legend line and inside is written mylegend. It does not grab the filenames I am clicking on.
what I needed is : when I click multiple files, and hold all the plots, the legend show a list of all those clicked and plotted files.
Ameer Hamza
2020년 3월 27일
Ok. Suppose you press hold button, then click two filenames, does it need to show both plots? Then you click the hold button again, what should happen if you click other filenames after that? Should I remove two previous plots or it should still keep them?
farzad
2020년 3월 27일
dear Ameer, as long as the hold button is pressed, it should keep any plot of the next clicked files with all the relevant legend in the legend list. Actually I somehow managed to solve it, but changing your code a little bit. just in case you don't want to dedicate time to that.
THANK YOU SO MUCH
farzad
2020년 4월 6일
dear Ameer, I think you can help me with this new question of mine, it's relevant to this one :
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)