Find for each value of a vector
이전 댓글 표시
Is there a way to speed up of vectorize the following?
L=length(X)
v=1:L
for n=1:L
v(n)=find((X(n) >= Y), 1, 'last')
end
Thanks in advance.
댓글 수: 2
Yao Li
2013년 4월 16일
You'd better explain your work in details.
Walter Roberson
2013년 4월 16일
I take it that Y is a vector?
Is there a reason you initialized v to 1:L instead of zeros(1,L) ?
What if x(n) is less than all Y ?
답변 (1개)
Andrei Bobrov
2013년 4월 16일
v = max(bsxfun(@times,bsxfun(@ge,X(:),Y(:)'),1:numel(Y))),[],2);
카테고리
도움말 센터 및 File Exchange에서 SimEvents에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!