필터 지우기
필터 지우기

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

조회 수: 1 (최근 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?

답변 (2개)

Voss
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.

Saurabh
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.
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.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by