Splitting rectangle into smaller rectangles using fractions

4 views (last 30 days)
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!

Answers (1)

Taylor
Taylor on 14 Nov 2024
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.

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!