彩色 MATLAB 罗盘图
我对 MATLAB 很陌生,因此非常感谢您的帮助。
我想使用 MATLAB 的 compass 图可视化多个向量。是否可以对不同的向量进行着色?这些向量随着时间的推移而变化,并且它们传递给罗盘图的顺序永远不会改变。还有其他方法来区分向量吗?
先感谢您! M.
编辑:该解决方案有效(即箭头是彩色的),直到到达罗盘的最后一个向量元素。如果我之前没有停止循环,该方法将退出并出现错误??? 下标索引必须是实数正整数或逻辑数。
罗盘的每个对象(即箭头)都被正确定位,除了最后一个;检查了索引,一切似乎都正常。我能做什么?
这是我当前使用的代码:
handle = compass(viewframe(1,:),viewframe(2,:));
colors = get(0,'DefaultAxesColorOrder');
for i=1:length(handle)
set(handle(i),'color', colors(mod(i,length(colors)),:))
end
I'm quite new to MATLAB and therefore any help is very appreciated.
I want to visualize multiple vectors using MATLAB's compass graph. Is it possible to colorize the different vectors? Those vectors change over time and the order in which they're handed to the compass graph never changes. Is there another way to distinguish the vectors?
Thank you in advance!
M.
EDIT: The solution works (i.e. arrows are colored) until the very last vector element of the compass is reached. If I do not stop the loop before, the method exits with the error ??? Subscript indices must either be real positive integers or logicals..
Every object (i.e. arrows) of the compass is correctly adressed except the last; checked the indexes, everything seems to be ok.What can I do?
Here's the code I currently use:
handle = compass(viewframe(1,:),viewframe(2,:));
colors = get(0,'DefaultAxesColorOrder');
for i=1:length(handle)
set(handle(i),'color', colors(mod(i,length(colors)),:))
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基于 @cyborg 答案,您可以在一次调用中分配颜色:
< img src="https://i.sstatic.net/KwLs2.png" alt="compass">
您还可以使用图例进行注释:
Building on @cyborg answer, you could assign the colors in one call:
You could also use a legend for annotation:
你可以这样做:
You could do this: