[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: element extraction from vector
From: |
Vic Norton |
Subject: |
Re: element extraction from vector |
Date: |
Sun, 27 Dec 2009 18:28:16 -0500 |
Try this, Hassen, following Jaroslav's "find" technique:
A = rand(10, 5) - ones(10, 5) * 0.5;
A = A .* (abs(A) < 0.3);
for j = 1 : columns(A)
B(j).j = j;
B(j).w = w = find(A(:, j));
B(j).v = A(w, j);
endfor
Now look at A and B(1), B(2), B(3), B(4), and B(5). Isn't this what you want?
Regards,
Vic
On Dec 27, 2009, at 5:09 PM, address@hidden wrote:
> Vic and Jaroslav, thank you very much.
> is it possible to do the job for a matrix X? i.e. for every column of X, we
> obtain a vector of nonzero elements of this column and their indices in this
> column. I remark that the function 'find' stoke the nonzero elements of the
> matrix in a row vector so that when we look at the output, we can not have an
> idea of the nonzero elements of each column or their indices.
> I hope that I don't disturb you.
>
> ____________________________________________________
>
> Tables en fĂȘte, recettes parfaites, sorties en goguette tout est sur
> http://evenementiel.voila.fr/Noel
>
>
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave