MATLAB: [1 0 1 1 0 1 1 0] to [10 11 01 10]

matrix manipulationvector

I need to transform 8 numbers into 4 like the title, how could i do that?

Best Answer

  • V = [1 0 1 1 0 1 1 0];
    one_way = V(1:2:end) * 10 + V(2:2:end)
    another_way = reshape(V, 2, []).'