Dataset to Square Wave

1 回表示 (過去 30 日間)
Martin Androvich
Martin Androvich 2018 年 4 月 30 日
コメント済み: Martin Androvich 2018 年 5 月 4 日
I have an array of datapoints; y being a boolean and x being some distance at which that boolean is changed.
I can plot it just fine, but I was wondering if there was an simple and quick way of converting the "usual" linear plot such that the data is represented with rising and falling edges, like a square wave, as pictured below:
I can do this manually, but there might be a neat way of doing so that I don´t know of.

採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 5 月 1 日
a little awkward, but should serve you well
x=[0 32 37 45 53]';
y=[0 1 0 1 0]';
a=x([2:end,end]);
a=reshape([x,a]',[],1);
b=reshape([y,y]',[],1);
plot(a,b,'r*-')
  1 件のコメント
Martin Androvich
Martin Androvich 2018 年 5 月 4 日
Brilliant, thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by