How to position all the plots in app designer using matlab

49 次查看(过去 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,11:11
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,5:03
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