Is it possible to do this without for cycle?

 Respuesta aceptada

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

2 comentarios

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

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 19 de Mzo. de 2018

Comentada:

el 20 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by