|
On Feb 10, 7:04 pm, "Sean de "
<sean.dewol...@nospamplease.umit.maine.edu> wrote:
> "Hannes Furuholm" wrote in message <ij12qf$6...@fred.mathworks.com>...
> > Hi! Newbie here..
> > I have a matrix (100x36) and a vector (1x36). The values of the vector are somewhat similar to the ones in the matrix, and what I want to do is to find (and list) which values in the matrix that exceeds the vector values by more than "10". And this for each of the 36 different columns.
>
> > However, since there are different amount of exceeding numbers for each of the 36 columns, it seems like a regular for-loop wont work.
>
> > for i=1:36
> > s(i)=find(matrix(:,F(i))>(vector(i)+10));
> > end
>
> > this since "s" would not have sufficient number of elements. I have i.e. 36 new vectors of different length and want to put them all in a new matrix. Is this even possible?
>
> > I hope my problem is understandable, any suggestions on how I should approach it? I might add that my code works well as long as I just do it one vector at a time (replacing the index with a specific column number).
>
> > Best regards
> > // Hannes
>
> No reason for a for-loop. That why they made BSXFUN.
>
> %Data
> A = 1:36;
> B = floor(rand(100,36)*50);
>
> %Engine
> sum(bsxfun(@(x,y)(y-x)>10,A,B))
>
> %SCd
Can we use BSXFUN with arrays of objects (oop) so we can call methods
of a class?
|