Is it possible to do this without for cycle?

 채택된 답변

Jos (10584)
Jos (10584) 2018년 3월 19일

0 개 추천

% data
Y = [1 1 3 2 3 1 1 2] % M = numel(Y)
K = 3
% engine
T = double((Y(:) - (1:K))==0)

댓글 수: 2

Mr M.
Mr M. 2018년 3월 20일
beautiful, thanks
The above code requires R2016b or later. Earlier versions would need to use bsxfun()

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 C2000 Microcontroller Blockset에 대해 자세히 알아보기

태그

질문:

2018년 3월 19일

댓글:

2018년 3월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by