How do I create a (n x n) matrix whose elements alternate 1 or 0?
Mostrar comentarios más antiguos
How do I create a (n x n) matrix whose elements are either 1 or 0 such that the value of each element is different from its adjacent elements, both from those above and below it and from those on either side of it.
Respuestas (2)
Roger Stafford
el 4 de Abr. de 2015
M = toeplitz(mod(1:n,2),mod(1:n,2));
1 comentario
Jos (10584)
el 4 de Abr. de 2015
M = mod(toeplitz(1:n),2)
Matt J
el 4 de Abr. de 2015
[I,J]=ndgrid(1:n);
A=((-1).^(I+J)+1)/2
Categorías
Más información sobre State-Space Control Design and Estimation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!