Akzeptierte Antwort

Jos (10584)
Jos (10584) am 19 Mär. 2018

0 Stimmen

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

2 Kommentare

Mr M.
Mr M. am 20 Mär. 2018
beautiful, thanks
Walter Roberson
Walter Roberson am 20 Mär. 2018
The above code requires R2016b or later. Earlier versions would need to use bsxfun()

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by