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

You could use a custom datacursormode callback to display sqrt(u^2+v^2) as part of the output.
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 Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by