scale_quivers

版本 1.0.1 (1.6 KB) 作者: Michael Xie
Scales multiple quiver plots to use the same length scale.
130.0 次下载
更新时间 2018/11/8

查看许可证

SCALE_QUIVERS(QH, SCALE) scales multiple quiver plots to use the same length scale (by default, the longest vector)
QH is a vector of handles to the quiver plots. Note that a handle of a quiver plot can be easily obtained via 'qh = quiver(...)'.
SCALE is a user-defined final scaling factor. Once the vectors have been equally scaled between the subplots, the arrow lengths are then multiplied by this value.
-------------------------------------------------------------------------------------
Use case:
The user has multiple quivers which should be scaled the same.
The built-in QUIVER command can turn off autoscale for all quivers so that they are scaled the same. However, some vector arrows may have an inappropriate length (too large and overlapping or too small). Since autoscale is off, there is no easy way to rescale ALL vector arrows concurrently.
SCALE_QUIVERS addresses this issue. This function only needs to be called once near the end of the script after all relevant quivers have been plotted.
-------------------------------------------------------------------------------------
Example:
load wind
a = cellfun(@(x) x(1:end,1:end,1), {x,y,z, u,v,w}, 'uniformoutput',0);
x = a{1}; y = a{2}; z = a{3};
u = a{4}; v = a{5}; w = a{6};
u2 = u/2; v2 = v/2; w2 = w/2;

subplot(2,2,1)
q1 = quiver(x,y,u,v,0); title('original (autoscale off)')
subplot(2,2,2)
q2 = quiver(x,y,u2,v2,0); title('halved (autoscale off)')

subplot(2,2,3)
q3 = quiver(x,y,u,v,0); title('original (scaled by 30)')
subplot(2,2,4)
q4 = quiver(x,y,u2,v2,0); title('compressed (scaled by 30)')

scale_quivers([q3,q4],30)
-------------------------------------------------------------------------------------
The current script has been tested on Windows MATLAB R2018b for six 2D quiver plots.
-------------------------------------------------------------------------------------
Known issues and ideas for future features:
If any of the quivers is 2D, then SCALE_QUIVERS will assume all quivers are 2D (and hence delete any 3-dimensional data).
The user-defined SCALE currently has no physical meaning and will hence require trial and error for it to be useful.

MATLAB 版本兼容性
创建方式 R2018b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Vector Fields 的更多信息
标签 添加标签

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.1

Minor change to screenshot.
Removed in-script licensing info.

1.0.0