Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Problem rearranging vector (a column of a matrix)

4 visualizzazioni (ultimi 30 giorni)
Jon
Jon il 20 Apr 2014
Chiuso: MATLAB Answer Bot il 20 Ago 2021
Hi, similar to the 2048 game, on a 4x4 board with 1's, 2's, 4's and the following power of 2's, I'd like to write a slightly different game to it. The only problem I have is rearranging a vector such that by selecting 'up', c = [1, 1, 0, 4]' turns into c = [2, 4, 0, 0]'. I could use loops but can you think of a way to do it using logical ops?

Risposte (1)

Walter Roberson
Walter Roberson il 20 Apr 2014
c = mod(c .^ 2, 8);

Questa domanda è chiusa.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by