Splitting rectangle into smaller rectangles using fractions
1 次查看(过去 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. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1807514/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1807514/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1807519/image.png)
I'm fairly new to Matlab and super lost so any help would be appreciated!
0 个评论
回答(1 个)
Taylor
2024-11-14
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!