to plot binary data for the predefined time interval

5 ビュー (過去 30 日間)
ABDUL
ABDUL 2019 年 6 月 4 日
コメント済み: Guillaume 2019 年 6 月 4 日
how to plot binary input using matlab?
x=[1 1 1 0 0 1 0 1 1 0 0 0 ] , frequency is 8Mhz , also i need to plot odd and even samples for two bit interval. kindly help in this regard

採用された回答

Guillaume
Guillaume 2019 年 6 月 4 日
plot means many things. You need to clarify what sort of plot you want.
Possibly:
sampleddata = timetable(x(:), 'SampleRate', 8e6, 'VariableNames', {'sample'})
plot(sampleddata.Time, sampleddata.sample)
  2 件のコメント
ABDUL
ABDUL 2019 年 6 月 4 日
plot is a a digital waveform for the given data
Guillaume
Guillaume 2019 年 6 月 4 日
You're still not giving many details of what you want.
I'd be surprised if there isn't some plotting function for digital signals in the signal processing toolbox or dsp toolbox, but as I've got neither I don't know.
In base matlab, it's fairly easy to get a plot of a digitial signal:
x = [1 1 1 0 0 1 0 1 1 0 0 0 ]; %demo data
sampleddata = timetable(x(:), 'SampleRate', 8e6, 'VariableNames', {'sample'}) %a better way to store the data
stairs(sampleddata.Time, sampleddata.sample);
ylim([-0.5, 1.5]);

サインインしてコメントする。

その他の回答 (1 件)

Sayyed Ahmad
Sayyed Ahmad 2019 年 6 月 4 日
try something like this:
n=0;
while n<5000
for i=1:1000
t(i)=now;
x=[1 0 0 1 1 1 0 0 1]; %read your x from sensor
y(i)=sum(x.*2.^(length(x)-1:-1:0));
end
plot(t,y(end:-1:1))
pause(1e-3);
n=n+1;
end
  2 件のコメント
ABDUL
ABDUL 2019 年 6 月 4 日
it is taking an infinite loop for execution
Sayyed Ahmad
Sayyed Ahmad 2019 年 6 月 4 日
important is this part of code:
x=[1 0 0 1 1 1 0 0 1];
y(i)=sum(x.*2.^(length(x)-1:-1:0)); % change the binary digital signal to a dec. number
and
plot(t,y(end:-1:1)); % plotting for an acceptable time interval
It is yours, how you embaded the codes!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWaveform Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by