現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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
Ameer Hamza
2020 年 3 月 26 日
Please check the attached app. It have a state button to hold the graph.
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)