Réponse acceptée

Jos (10584)
Jos (10584) le 19 Mar 2018
% data
Y = [1 1 3 2 3 1 1 2] % M = numel(Y)
K = 3
% engine
T = double((Y(:) - (1:K))==0)

2 commentaires

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

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by