<div dir="ltr"><div><div><div><div><div><div>@ Claus:<br><br>...well actually I wanted to treat every coordinate separatly....so A would be my X coordinate of the map and B would be the x coordinate of the line.<br></div>Afterwarsd I would do the same with the Y-coordinate..<br><br></div>So I think my question expressed what I wanted to do in the beginning.<br><br></div>What I did not expect was, that the size of the arrays would matter (did not expect this memory issue).<br><br></div>Anyways....of course you are right.<br></div>Cheers,<br></div>Philipp<br><div><div><div> <br><div><div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mo., 18. Feb. 2019 um 18:32 Uhr schrieb Claus Futtrup <<a href="mailto:cfuttrup@gmail.com">cfuttrup@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 bgcolor="#FFFFFF">
<div class="gmail-m_-8272210635697132897moz-cite-prefix">Hi Philipp</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix">>problem solved.....I had to think
differently than before.</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix">Heh!</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix">It helps to know what you actually want
to do (and also the size of the problem).<br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix">Cheers,<br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix">Claus<br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix"><br>
</div>
<div class="gmail-m_-8272210635697132897moz-cite-prefix">On 18.02.2019 18:08, P M wrote:<br>
</div>
<blockquote type="cite">
<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" target="_blank">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_-8272210635697132897gmail-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>
<br>
<fieldset class="gmail-m_-8272210635697132897mimeAttachmentHeader"></fieldset>
<pre class="gmail-m_-8272210635697132897moz-quote-pre">_______________________________________________
users mailing list
<a class="gmail-m_-8272210635697132897moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a>
<a class="gmail-m_-8272210635697132897moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<p><br>
</p>
<div id="gmail-m_-8272210635697132897DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid rgb(211,212,222)">
<tbody><tr>
<td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" style="width: 46px; height: 29px;" height="29" width="46"></a></td>
<td style="width:470px;padding-top:12px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" style="color:rgb(68,83,234)" target="_blank">www.avast.com</a>
</td>
</tr>
</tbody></table><a href="#m_-8272210635697132897_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></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>