필터 지우기
필터 지우기

Modifying a quiver plot

조회 수: 5 (최근 30일)
Douglas Brenner
Douglas Brenner 2016년 10월 25일
댓글: Star Strider 2016년 10월 26일
Some of the arrows in my quiver plot are too big. I want to set them to zero using a for loops and a if statement. How do I write the if statement condition? Is there another way to do this? Thanks

답변 (1개)

Star Strider
Star Strider 2016년 10월 25일
The last two arguments to the quiver function are the x- and y-magnitudes of the arrows. If you want to set a length threshold, create a (Nx2) matrix of the magnitudes, use that as an argument to the hypot function (that will calculate the lengths), and then using logical indexing, set the magnitude rows to zeros of the lengths that exceed your desired threshold.
  댓글 수: 2
Star Strider
Star Strider 2016년 10월 26일
Douglas Brenner’s ‘Answer’ moved here
Don't understand your answer but that may just indicate my ignorance of matlab. In my case the quiver plot comes from the outputs of imgradientxy. Using those I can calculate the length of the vectors and for the ones that exceed a threshold set the components to zero.
Star Strider
Star Strider 2016년 10월 26일
I’m describing something like this:
uv = randi(99, 15, 2); % Create ‘u’ and ‘v’ As A Matrix
len = hypot(uv(:,1), uv(:,2)); % Calculate Lengths
lenv = len > 100; % Logical Vector, Length Threshold = 100
uv(len > 100,:) = repmat([0 0], sum(lenv),1); % Set ‘uv’ Rows Meeting Criteria To Zeros
That works.
It should be straightforward to make it work with your code.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by