Convert a vector to single element

3 vues (au cours des 30 derniers jours)
salah roud
salah roud le 22 Fév 2020
Modifié(e) : Andrei Bobrov le 25 Fév 2020
Hey
could someone tell me how to convert an vector to single element?
My code :
signal = [0];
for i = 1:255-1
signal(i) = dec2bin(i,8)
end
i get this error "the error is " Unable to perform assignment because the left and right sides have a different number of elements."
i want to get this result
singal = [0000000,00000001,00000010,.............. Ets ]
how could do that ?
and thank you :D

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 22 Fév 2020
Modifié(e) : Andrei Bobrov le 25 Fév 2020
signal = dec2bin((0:255)');
or
fullfact([2 2 2 2 2 2 2]) - 1;
in your case
for i = 256:-1:1
signal(i,:) = dec2bin(i-1,8);
end

Plus de réponses (1)

darova
darova le 22 Fév 2020
Use cells
signal = cell(254,1);
for i = 1:255-1
signal{i} = dec2bin(i,8);
end

Catégories

En savoir plus sur Communications Toolbox dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by