Plot binary sequence of type char (MATLAB)
显示 更早的评论
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 个评论
Fifteen12
2022-12-2
What have you tried so far? Love to help, but not sure what you're confused on!
high speed
2022-12-2
采纳的回答
更多回答(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])
类别
在 帮助中心 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

