How to track the vector magnitude in quiver plot?

Hello Matlabers,
When I use quiver to get a vector plot, I find that I couldn't use data cursor to track the value of the clicked point. Is it possible to do this by data cursor? If it's impossible, how can I do to get the vector magnitude when I click the arrow in the plot?
Thanks in advance.
Xiaoliang

 採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 1 日

1 投票

If you use quiver(x,y,u,v), the data cursor mode will show the (x,y,u,v) value for every point that is plotted. I guess you want the value of sqrt(u^2+v^2). That is not available in the plot. If you want to have that, you need to plot it somewhere in the figure.
use quiver(x,y,u,v,scale) to adjust the length of the arrow line.
Follow Doug's video tutorial to create a customized data cursor function. http://blogs.mathworks.com/videos/2011/02/25/creating-a-custom-data-cursor/

2 件のコメント

Walter Roberson
Walter Roberson 2011 年 11 月 1 日
You could use a custom datacursormode callback to display sqrt(u^2+v^2) as part of the output.
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 1 日
Good point, Walter! Now I recall one of Doug's video.

サインインしてコメントする。

その他の回答 (2 件)

xiaoliang
xiaoliang 2011 年 11 月 2 日

0 投票

To Fangjun,
Thanks very much. Actually, before I saw your answer, I had thought it was impossible to show (x,y,u,v) in quiver plot. Because every time I tried, it gave out an error, or a result like this [x: y : u: v:], that is, there was no value for them. After I read your reply, I went back to the help doc on quiver, and I used the example in it to test it. Finally, I located my problem. It seems that if you use quiver(u,v), you can get a correct vector plot sometimes, but you cannot use data cursor; however if you use quiver(x,y,u,v), then there is no problem at all!
xiaoliang
xiaoliang 2011 年 11 月 2 日

0 投票

And I have a another question. When doing data cursor, if I right click, select 'Edit text update function', then I save it as a .m file without any modification. After that, I do data cursor again, but this time I right click, and select test update function saved. Now, in the datatip, I can only see the value X and Y! Why??
Thanks in advance.
Xiaoliang

カテゴリ

ヘルプ センター および File ExchangeVector Fields についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by