Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: hide vectors in quiver plot completely
Date: Fri, 6 Nov 2009 00:29:19 +0000 (UTC)
Organization: Cranfield Univ
Lines: 40
Message-ID: <hcvqkv$8oh$1@fred.mathworks.com>
References: <hcsn0u$s36$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257467359 8977 172.30.248.35 (6 Nov 2009 00:29:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 6 Nov 2009 00:29:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1597547
Xref: news.mathworks.com comp.soft-sys.matlab:582892


Hello Fabian

One way to do it is not to include the zero vectors in the first place. You can scan through the flow field and exclude those of zero value from being plotted, like this:

function quiverTest(u,v)
% Initialise arrays
xx=[]; yy=[]; uu=[]; vv=[]; 
% Scan through all elements
for i=1:size(u,1)
    for j=1:size(u,2)
        if sqrt(u(i,j).^2+v(i,j).^2)~=0 % If it's a zero vector, ignore it, otherwise add it to the array
            xx=[xx i];
            yy=[yy j];
            uu=[uu u(i,j)];
            vv=[vv v(i,j)];
        end                
    end
end
% Quiver and reverse the Y axis.
quiver(xx,yy,uu,vv);
set(gca,'YDir','reverse');

Hope this helps,
M

"Fab Braun" <f1braun@hsr.ch> wrote in message <hcsn0u$s36$1@fred.mathworks.com>...
> hi all!
> 
> i'm dealing around with showing the optical flow of an image in a quiver plot.
> so far no problem, except I haven't found a solution yet to completely remove zero valued vectors from the quiver plot.
> 
> the following i read somewhere:
> Vectors(Vectors == 0) = nan;
> 
> bud this doesn't work 100%...because there is still a small point left everywhere i want to set these vectors to zero.
> 
> any other ideas?
> 
> thanks in advance!
> fabian