[Scilab-users] function find()

Pierre-Aimé Agnel pierre-aime.agnel at scilab-enterprises.com
Tue May 27 14:26:59 CEST 2014


Hi,

You are computing "operator<" over complex number (which is not defined) 
because your distance matrix has an error

Try with this change
distance(i,j) = sqrt((etat(i,1)-etat(j,1))**2+(etat(i,2)-etat(j,2)**2));
=>
distance(i,j) = sqrt((etat(i,1)-etat(j,1))**2+(etat(i,2)-etat(j,2))**2);

Full script:
// initialisation
diam = 0.2;
nd = 10;
etat = (rand(nd,2) -0.5)*4;
distance = zeros(nd,nd);
//compute distance matrix
for i = 1:(nd-1)
     for j = (i+1):nd
         distance(i,j) = 
sqrt((etat(i,1)-etat(j,1))**2+(etat(i,2)-etat(j,2))**2);
     end
end
//find close pairs
[li,lj] = find(distance<diam)

Best,

On 05/27/2014 01:49 PM, grivet wrote:
> Hello,
> While trying to compute pairwise distances between random points, I 
> have come across
> a behavior of function find() that I don't understand. I do the 
> following:
>
> // initialisation
> diam = 0.2;
> nd = 10;
> etat = (rand(nd,2) -0.5)*4;
> distance = zeros(nd,nd);
> //compute distance matrix
> for i = 1:(nd-1)
>     for j = (i+1):nd
>         distance(i,j) = 
> sqrt((etat(i,1)-etat(j,1))**2+(etat(i,2)-etat(j,2)**2));
>     end
> end
> //find close pairs
> [li,lj] = find(distance<diam)
>
> With both Scilab 5.4.1 and Scilab 5.5, the last line raises the error 
> message:
>                          !--error 144
> Opération non définie pour les opérandes données.
>
> I will be grateful to anybody who spots my error.
>
> Thank your for your time,
> JP Grivet
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-- 
Pierre-Aimé Agnel
Development Team
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
http://www.scilab-enterprises.com




More information about the users mailing list