[Scilab-users] convert matlab code to scilab
Samuel Gougeon
sgougeon at free.fr
Mon Oct 28 13:51:24 CET 2019
Le 16/10/2019 à 13:27, Stéphane Mottelet a écrit :
>
> Sorry, in my answer the loop constructs "ic", not "ia", i.e. the full
> equivalent to Matlab's "[C,ia,ic] = unique(A)" is in Scilab:
>
> [C,ia] = unique(A)
> for i=1:length(A)
> ic(i)=find(A(i)==C)
> end
>
ic = ones(A);
for i = 1:length(ia)
ic(A==C(i)) = i;
end
// Check:
and(A==C(ic))
will be always (much) shorter and faster (in case of high redundancy).
Samuel
More information about the users
mailing list