How to get 3 different plots in 1 plot axes using drop down button followed by analyse button in GUI?
2 次查看(过去 30 天)
显示 更早的评论
I'm trying to add dropdown in GUI to get user selected plot in same plot axes. The data required to plot should be taken by user selected excel file. So, every time while selecting the options in dropdown, it was asking the excel file from user and again while pressing the analyse button it was asking the excel file from user. how can i code to solve the issue of asking excel file at both dropdown and analyse button?
0 个评论
回答(2 个)
Voss
2024-3-18
Prompt the user to select the file (e.g. by calling uigetfile) only in the callback of the button the user clicks to select a file.
Do not prompt the user to select a file in the drop-down callback or the analyze button callback.
0 个评论
Saurabh
2024-3-19
Hello Purna,
It is unclear which approach was utilized for plotting the graph. In order to assist, here is an overview of the method employed by me for generating three distinct plots based on the user's selection from a dropdown menu. Additionally, a screenshot is provided for reference to facilitate a clearer understanding.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1645851/image.png)
The callback function linked to the "Analyze" button is structured as the following lines of code:
file = app.DropDown.Value;
% disp(file);
if file == 'Excel1'
data = readtable('Excel1.xlsx');
plot(app.UIAxes, data.Var1, data.Var2);
elseif file == 'Excel2'
data = readtable('Excel2.xlsx');
plot(app.UIAxes, data.Var1, data.Var2);
else
data = readtable('Excel3.xlsx');
plot(app.UIAxes, data.Var1, data.Var2);
end
Please note that necessary adjustments are required in the code attached above to align with the specified requirements .
For more information you can refer this documentation to understand more about App designer and drop-down properties:
- https://www.mathworks.com/help/matlab/ref/appdesigner.html?s_tid=srchtitle_site_search_1_appdesigner
- https://www.mathworks.com/help/matlab/ref/matlab.ui.control.dropdown-properties.html?searchHighlight=Drop%20down&s_tid=srchtitle_support_results_1_Drop%20down
I hope this was helpful.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!