Hi Philipp

>problem solved.....I had to think differently than before.

Heh!

It helps to know what you actually want to do (and also the size of the problem).

Cheers,
Claus

On 18.02.2019 18:08, P M wrote:
problem solved.....I had to think differently than before.

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.

The map is of width:    900    // in reality the map is based on an image with 900x1500 pixels
The map is of height: 1500

The points are building a line on the map...e.g: the line consists of 1076 points
So from the map I have build:

x = map(1,:);   // contains all x coordinates of the map
y = map(2,:);   // contains all y coordinates of the map

points = [ lineX, lineY];      // points contain the X-Y-coordinates of the line

for i = 1:n
     actPoint = points(i,:);
     [nearestX xInd]   = min(abs(actPoint(1)-x));
     [nearestY yInd]  = min(abs(actPoint(2)-y));
     nearestPoint(i,:) = [x(xInd) y(yInd)];
end


This is what works for now, though it is still slow.

For searching 100 points of the line it needs about 10 seconds.
For searching 200 points of the line it needs about 19 seconds.
For searching 500 points of the line it needs about 45 seconds.
For searching 1000 points of the line it needs about 98 seconds.







Am Mo., 18. Feb. 2019 um 16:39 Uhr schrieb P M <[email protected] <mailto:[email protected]>>:

    Ok, thanks for your help..

    Actually the sizes I gave where just for demonstation.

    If I use the real array sizes, I get a message: can not allocate 
    7469.60MB memory...which maybe is true.
    available RAM after starting Scilab is 3701 MB

    actual array sizes:

    A has 1076 elements
    B has 1'350'000 elements, with a lot of Nan's in it

    if I use thrownan(B) I can reduce the array size of B to 867751
    elements but still get the Message above.

    (without thrownan() the memory scilab wants to allocate is even
    bigger)




    Am Fr., 15. Feb. 2019 um 23:25 Uhr schrieb Samuel Gougeon
    <[email protected] <mailto:[email protected]>>:

        ... and even clearer, with respect to your own notations:

        --> A = rand(1,1000);  // test's data
        --> B = rand(1,10000);
        --> [a, b] = ndgrid(A, B);
        --> size(a)  // same for b
         ans  =
           1000.   10000.
        --> [v, i] = min(abs(a-b), *"c"*);

        _______________________________________________
        users mailing list
        [email protected] <mailto:[email protected]>
        http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to