[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Indirect Addressing Question
From: |
Mirek Kwasniak |
Subject: |
Re: Indirect Addressing Question |
Date: |
Wed, 14 Nov 2001 21:55:01 +0100 |
User-agent: |
Mutt/1.3.23i |
Hi,
I have an alternative to Etienne. I solved Andreas problem this way:
[qv qcount] = count_unique(q(1:5));
a(qv)=a(qv)+10.*qcount
Where count_unique is defined as below:
function [ y, count ] = count_unique( x )
if length(x)==0;
y=[];
return;
end;
y = sort( x );
i = find( diff( [ inf; y(:) ] ) ~= 0 ) ;
y = y( i );
if nargout > 1
count = diff([ i(:); length(x)+1 ]);
count = reshape( count, size(y) );
end
It is maybe not so universal (works only on vectors) but I use
count_unique for many similar problems.
Mirek
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Indirect Addressing Question, Etienne Grossmann, 2001/11/14
- Re: Indirect Addressing Question,
Mirek Kwasniak <=
- Re: Indirect Addressing Question, Paul Kienzle, 2001/11/14
- overloading functions (Was: Indirect Addressing Question), adler, 2001/11/15
- Re: overloading functions (Was: Indirect Addressing Question), Paul Kienzle, 2001/11/16
- Re: overloading functions (Was: Indirect Addressing Question), John W. Eaton, 2001/11/16
- Re: overloading functions (Was: Indirect Addressing Question), adler, 2001/11/16
- Re: overloading functions, Paul Kienzle, 2001/11/20
- semantics of sum, prod, cumsum etc., adler, 2001/11/22
- Re: Indirect Addressing Question, adler, 2001/11/15