Plot binary sequence of type char (MATLAB)
Afficher commentaires plus anciens
Dear,
I have this binary sequence '011010001000000001010011' of type char, and I want to plot it to obtain a graph like that for example:

2 commentaires
Fifteen12
le 2 Déc 2022
What have you tried so far? Love to help, but not sure what you're confused on!
high speed
le 2 Déc 2022
Réponse acceptée
Plus de réponses (1)
seq = randi(2, [1, 20]) - 1;
y = seq(1);
x = 0;
for i = 1:length(seq)-1
y(end+1) = seq(i);
x(end+1) = i;
if seq(i+1) ~= seq(i)
y(end+1) = seq(i+1);
x(end+1) = i;
end
end
plot(x, y)
axis([0, x(end), -2, 3])
Catégories
En savoir plus sur Descriptive Statistics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

