Clear Filters
Clear Filters

How to get 3 different plots in 1 plot axes using drop down button followed by analyse button in GUI?

1 view (last 30 days)
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?

Answers (2)

Voss
Voss on 18 Mar 2024
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.

Saurabh
Saurabh on 19 Mar 2024
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.
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:
I hope this was helpful.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!