【发布时间】:2015-03-20 06:55:44
【问题描述】:
我正在使用 MATLAB 并想使用 rectangle 函数来绘制一个矩形。我希望用户输入每个角的坐标。我写了以下内容:
xR1 = input('x coordinate of the first rectangle corner?');
yR1 = input('y coordinate of the first rectangle corner?');
xR2 = input('x coordinate of the second rectangle corner?');
yR2 = input('y coordinate of the second rectangle corner?');
xR3 = input('x coordinate of the third rectangle corner?');
yR3 = input('y coordinate of the third rectangle corner?');
xR4 = input('x coordinate of the fourth rectangle corner?');
yR4 = input('y coordinate of the fourth rectangle corner?');
XRcoordinates = [xR1 xR2 xR3 xR4]
YRcoordinates = [yR1 yR2 yR3 yR4]
width = max(XRcoordinates) - min(XRcoordinates)
height = max(YRcoordinates) - min(YRcoordinates)
rectangle('Position', min(XRcoordinates), min(YRcoordinates),width,height)
axis([0 max(XRcoordinates) 0 max(YRcoordinates) ])
当我运行它时,我输入以下内容
xR1 = 2
yR1 = 3
xR2 = 2
yR2 = 5
xR3 = 4
yR3 = 5
xR4 = 4
yR4 = 3
但我收到以下错误消息:
使用
rectangle时出错无法为此对象指定便利参数
script1中的错误(第 37 行)
rectangle('Position', min(XRcoordinates),min(YRcoordinates),width,height)
第一条错误信息是什么意思? 怎么了?
【问题讨论】:
-
我的回答解决了你的问题吗?
-
是的,非常感谢@rayrengspan>
-
没问题!感谢您接受 :) 祝你好运!
标签: image matlab plot rectangles