h = drawrectangle('Position',[50,50,14,57],'Rotatable',1)
But using drawpolygon, I don't have the same flexibility and get an error if I add in rotatable. The variable "vertices" holds my x and y values.
h = drawpolygon('Position', vertices,'InteractionsAllowed', 'translate', 'LineWidth', 1);
Here's a solution that you can tweak to your liking. As demonstrated below, the code creates a red rotatable rectangle around the polygon object. Rotate the red rectangle and double click to confirm. The original polygon will rotate correspondingly.
imshow(ones(1000)); my_vertices = [500 500;400 600;400 700;500 800;600 800;700 700; 700 600]; h = drawpolygon('Position',my_vertices); manualRotate(h);
function manualRotate(h) [xl,yl]=polyshape(h.Position).boundingbox; dx=diff(xl); dy=diff(yl); c=[xl(1)+dx/2, yl(1)+dy/2]; hr = drawrectangle('Position',[xl(1),yl(1), dx, dy],'Rotatable',1,'Color','r'); wait(hr) t=hr.RotationAngle; R=[cosd(t) -sind(t);sind(t) cosd(t)]; h.Position=(h.Position-c)*R +c; delete(hr); end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.