<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: K-Nearest Neigbors and Radius (Range) Search</title>
	<atom:link href="http://www.advancedmcode.org/k-nearest-neigbours-search.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.advancedmcode.org/k-nearest-neigbours-search.html</link>
	<description>Open Blog with: Engineering Solutions, Algorithms, Advanced Matlab Source Code and Science related contents</description>
	<lastBuildDate>Thu, 11 Mar 2010 12:10:59 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Luigi Giaccari</title>
		<link>http://www.advancedmcode.org/k-nearest-neigbours-search.html/comment-page-1#comment-304</link>
		<dc:creator>Luigi Giaccari</dc:creator>
		<pubDate>Mon, 12 Oct 2009 17:53:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.advancedmcode.org/?p=241#comment-304</guid>
		<description>Try this:

&lt;pre lang=&quot;MATLAB&quot;&gt;
N=1000;%number of reference points
Nq=10;%number of query points
dim=3;%dimension of points
r=.2;%Search radius

p=rand(N,dim);
qp=rand(Nq,dim);

A=sparse(N,N);%building the sparse matrix

for i=1:Nq
idc=BruteSearchMex(p&#039;,qp(i,:)&#039;,&#039;r&#039;,r);%%Radius Neighbor
m=length(idc);%number of neighbours found
A([i*ones(1,m),idc],[idc,i*ones(1,m)])=1;%add element to matrix
end
&lt;/pre&gt;

Consider that sparse matrix in Maltab is class defined for doubles. So if you want a logical amtrix you need to use:

&lt;pre lang=&quot;MATLAB&quot;&gt;
A=false(N,N);
&lt;/pre&gt;

It depends on what are your requirements.

Second, yes radius can be different. Radisu search supports only one query time so you have to call the rourtine each loop.

Good luck

Luigi</description>
		<content:encoded><![CDATA[<p>Try this:</p>

<div class="wp_syntax"><div class="code"><pre class="matlab" style="font-family:monospace;">N=<span style="color: #33f;">1000</span>;<span style="color: #228B22;">%number of reference points</span>
Nq=<span style="color: #33f;">10</span>;<span style="color: #228B22;">%number of query points</span>
dim=<span style="color: #33f;">3</span>;<span style="color: #228B22;">%dimension of points</span>
r=.2;<span style="color: #228B22;">%Search radius</span>
&nbsp;
p=<span style="color: #0000FF;">rand</span><span style="color: #080;">&#40;</span>N,dim<span style="color: #080;">&#41;</span>;
qp=<span style="color: #0000FF;">rand</span><span style="color: #080;">&#40;</span>Nq,dim<span style="color: #080;">&#41;</span>;
&nbsp;
A=<span style="color: #0000FF;">sparse</span><span style="color: #080;">&#40;</span>N,N<span style="color: #080;">&#41;</span>;<span style="color: #228B22;">%building the sparse matrix</span>
&nbsp;
<span style="color: #0000FF;">for</span> <span style="color: #33f;">i</span>=<span style="color: #33f;">1</span>:Nq
idc=BruteSearchMex<span style="color: #080;">&#40;</span>p',qp<span style="color: #080;">&#40;</span><span style="color: #33f;">i</span>,:<span style="color: #080;">&#41;</span>',<span style="color:#A020F0;">'r'</span>,r<span style="color: #080;">&#41;</span>;<span style="color: #228B22;">%%Radius Neighbor</span>
m=<span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>idc<span style="color: #080;">&#41;</span>;<span style="color: #228B22;">%number of neighbours found</span>
A<span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color: #33f;">i</span>*<span style="color: #0000FF;">ones</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>,m<span style="color: #080;">&#41;</span>,idc<span style="color: #080;">&#93;</span>,<span style="color: #080;">&#91;</span>idc,<span style="color: #33f;">i</span>*<span style="color: #0000FF;">ones</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>,m<span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>=<span style="color: #33f;">1</span>;<span style="color: #228B22;">%add element to matrix</span>
<span style="color: #0000FF;">end</span></pre></div></div>

<p>Consider that sparse matrix in Maltab is class defined for doubles. So if you want a logical amtrix you need to use:</p>

<div class="wp_syntax"><div class="code"><pre class="matlab" style="font-family:monospace;">A=false<span style="color: #080;">&#40;</span>N,N<span style="color: #080;">&#41;</span>;</pre></div></div>

<p>It depends on what are your requirements.</p>
<p>Second, yes radius can be different. Radisu search supports only one query time so you have to call the rourtine each loop.</p>
<p>Good luck</p>
<p>Luigi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arne Bøckmann</title>
		<link>http://www.advancedmcode.org/k-nearest-neigbours-search.html/comment-page-1#comment-302</link>
		<dc:creator>Arne Bøckmann</dc:creator>
		<pubDate>Mon, 12 Oct 2009 16:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.advancedmcode.org/?p=241#comment-302</guid>
		<description>Could you provide an example on how to find the sparse connectivity matrix with a specified cut-off radius ? Could this radius also differ from point to point?</description>
		<content:encoded><![CDATA[<p>Could you provide an example on how to find the sparse connectivity matrix with a specified cut-off radius ? Could this radius also differ from point to point?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
