简体   繁体   English

从两个角点生成矩形坐标的巧妙方法?

[英]Neat way of generating rectangle coordinates from two corner points?

I'm plotting a box in Matlab from four coordinates. 我正在从四个坐标在Matlab中绘制一个框。 Is there a neater way to generate these vectors than writing them out explicitly? 有没有比明确地​​写出它们更整洁的方法来生成这些矢量了?

plot( ...
    [x_min x_max; x_min x_max; x_min x_min; x_max x_max], ...
    [y_min y_min; y_max y_max; y_min y_max; y_min y_max], ...
    '-r' );

In my case, the variables are called lat_min and ax_min , which means that the above lines won't fit into 80 characters. 在我的情况下,这些变量称为lat_minax_min ,这意味着以上各行不能容纳80个字符。 And I'd really like that, since I'm going to print the code. 我真的很喜欢,因为我要打印代码。

How about using rectangle : 如何使用rectangle

pos = [ax_min, lat_min, ax_max - ax_min, lat_max - lat_min];
rectangle('Position', pos, 'EdgeColor', 'r')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM