How to position all the plots in app designer using matlab

조회 수: 1 (최근 30일)
Vaibhavi Pallavaneni
Vaibhavi Pallavaneni 2024년 9월 27일
댓글: Vaibhavi Pallavaneni 2024년 9월 30일
Hello all, I have created an app, Let me give brief details about it. The app starts with giving number of classes edit field and a enter button. If I give Number of classes as 2, a tab group with 2 tabs will open. In each tab there will be option like click to enter input parameters. After clicking that button, Classroom number label with its editfield and enter button appears. After giving Classroom number as 402 and click enter, Number of columns editfield with enter button will appear. After enterings number of columns in classroom as 4 and click enter, those many input boxes will generate with enter button. After giving strength of each input column as 25,35,42,18 and click enter. Number of benches for each column label and based on the columns input that many input boxes for the benches also generates along with enter button. After entering the benches value in each input box as 3,4,5 and click enter. Import excel buttons are generated based on the input given in the number of benches for each column. after clicking, import excel buttons the plots related to the excel files will be generated in the tab. But the number of plots are generated based on the number of columns value. But it should generate based on the number of benches in each column. I'm attaching my app file to this question. Please help me to resolve this issue.

답변 (1개)

Rushikesh
Rushikesh 2024년 9월 27일
I understand you want to generate a number of plots equal to the number of benches, but your current code is creating plots based on the number of columns due to a logical error.
Currently, the “ImportexcelButtonPushed” function iterates over the number of columns to create plots, whereas it should iterate over the number of benches instead. Here's an example of how you can achieve this:
initialPosition = [650, 675, 250, 300]; % Starting position for the first plot
plotIndex = 1; % Index to track plot position
for r = 1:numColumnBoxes
numBenches = app.BenchInputBoxes{Classroom}(r).Value;
for s = 1:numBenches
columnposition = initialPosition + [(plotIndex-1)*350, 0, 0, 0];
app.BoysVsGirls{Classroom, plotIndex} = uiaxes(tab, 'Position', columnposition);
plot(app.BoysVsGirls{Classroom, plotIndex}, Boys, Girls, '--b', BoysCu, GirlsCu, 'rX', BoysCu_real, GirlsCu_real, 'bO', 'LineWidth', 1);
plotIndex = plotIndex + 1; % Increment plot index for next plot position
end
end
Here outer loop iterates over columns, but the inner loop iterates over benches, allowing you to create plots for each bench and ‘plotIndex’ variable is used to track the position for each plot.
Let me know if this helps.
  댓글 수: 1
Vaibhavi Pallavaneni
Vaibhavi Pallavaneni 2024년 9월 30일
Hello@Rushikesh, First of all thanks for the code. There is a problem in the code. The plots are not matching the input. Let me explain in detail, The format of the plots should exactly replicate the import excel buttons format. The criteria is after clicking one excel button one plot should show in the tab section or else we can add another button named as plot below the all excel buttons. After clicking that plot button all the different data files choosen in the excel buttons should be plotted. Can u help to get this type of positioning in the app?

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by