How to position all the plots in app designer using matlab
1 次查看(过去 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.
0 个评论
回答(1 个)
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!