Splitting rectangle into smaller rectangles using fractions

42 次查看(过去 30 天)
I am trying to write a program that prompts user to draw a rectangle then ask for a fraction to then be split up into smaller sections. Essentially writing a code to make it so I can make example problems for math students and don't have to do this (see picture) one by one in google sheets.
So far I got to code it so the user can click and draw a rectangle and drag or edit the size of the rectangle but I have no idea how to go about splitting up the rectangle into sections like in the picture above.
I'm fairly new to Matlab and super lost so any help would be appreciated!

回答(1 个)

Taylor
Taylor 2024-11-14,15:51
If you have the Image Processing Toolbox, the drawrectangle function makes this fairly trivial. The rectangle ROI object it returns has a Position property that contains the x- and y-coordinates of the upper left corner of the rectangle as well as its height and width. From there you can just divide it into however many sections you like.

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by