<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div>problem solved.....I had to think differently than before.<br><br></div>Actually my goal was to compare point coordinates to map coordinates and find the points on the map which are closest to the given point coordinates.<br><br></div><div>The map is of width: 900 // in reality the map is based on an image with 900x1500 pixels<br></div><div>The map is of height: 1500<br></div><div><br></div><div>The points are building a line on the map...e.g: the line consists of 1076 points<br></div><div>So from the map I have build:<br><br></div><div>x = map(1,:); // contains all x coordinates of the map<br>y = map(2,:); // contains all y coordinates of the map</div><div><br></div><div>points = [ lineX, lineY]; // points contain the X-Y-coordinates of the line<br><br>for i = 1:n<br> actPoint = points(i,:);<br> [nearestX xInd] = min(abs(actPoint(1)-x));<br> [nearestY yInd] = min(abs(actPoint(2)-y));<br> nearestPoint(i,:) = [x(xInd) y(yInd)];<br>end</div><div><br><br></div><div>This is what works for now, though it is still slow.<br></div><div><br>For searching 100 points of the line it needs about 10 seconds.<br>For searching 200 points of the line it needs about 19 seconds.</div><div>For searching 500 points of the line it needs about 45 seconds.<br>For searching 1000 points of the line it needs about 98 seconds.</div><div><br><br><br><br></div><br><div><br></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mo., 18. Feb. 2019 um 16:39 Uhr schrieb P M <<a href="mailto:p.muehlmann@gmail.com">p.muehlmann@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Ok, thanks for your help..<br><br></div><div>Actually the sizes I gave where just for demonstation.<br><br></div><div>If I use the real array sizes, I get a message: can not allocate 7469.60MB memory...which maybe is true.<br></div><div>available RAM after starting Scilab is 3701 MB<br><br></div><div>actual array sizes:<br><br>A has 1076 elements<br></div><div>B has 1'350'000 elements, with a lot of Nan's in it<br><br></div><div>if I use thrownan(B) I can reduce the array size of B to 867751 elements but still get the Message above.<br><br></div><div>(without thrownan() the memory scilab wants to allocate is even bigger)<br></div><div><br><br><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Fr., 15. Feb. 2019 um 23:25 Uhr schrieb Samuel Gougeon <<a href="mailto:sgougeon@free.fr" target="_blank">sgougeon@free.fr</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<div class="gmail-m_5577763922447151768gmail-m_3771141033949040913moz-cite-prefix">... and even clearer, with respect to
your own notations:<br>
<br>
<font size="-1"><tt>--> A = </tt></font><font size="-1"><tt><font size="-1"><tt>rand(1,1000);</tt></font></tt></font><font size="-1"><tt> // test's data</tt></font><font size="-1"><tt><font size="-1"><tt> <br>
--> B = rand(1,10000);</tt></font><br>
--> [a, b] = ndgrid(A, B);</tt><tt><br>
</tt><tt>--> size(a)</tt><tt> // same for b<br>
</tt><tt> ans =</tt><tt><br>
</tt><tt> 1000. 10000.</tt><tt><br>
</tt><tt>--> [v, i] = min(abs(a-b), </tt></font><tt><b>"c"</b></tt><font size="-1"><tt>);</tt></font><br>
</div>
<br>
</div>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
</blockquote></div>
</blockquote></div>