[MATLAB INDEXING]

So what I'm trying to do is find the greatest negative number smallest positive number, respectively, in an array B=[f(a) f(b) f(c) f(d) f(e)] by using find(max(B(B<0))) and find(min(B(B>0))) and since that gives back an where in the array it is, use that value to get the value in the array A=[a b c d e], but I'm messing up somewhere and i can't figure out what I'm doing wrong....

A = [qp qn p a b]; [B] = arrayfun(f,A); a1= find(max(B(B<0))); b1= find(min(B(B>0))); %C=[a qp qn p f(p) b]; %h=[h;C]; a=A(a1); b=A(b1);

this is my code right now (this is situated in a while loop) any help would be appreciated. Thank you!!

Posted Feb 25, 2016, 1:24 AM UTC

34
Loading comments…