how to plot binary input

7 ビュー (過去 30 日間)
kumud alok
kumud alok 2016 年 3 月 9 日
回答済み: Guillaume 2016 年 3 月 9 日
my data matrix has 19 rows and 396 columns.
row 1=[0 1 0 1......]
row 2=[1 0 1 1 1 0...]
.
.
row 19=[0 1 0 1 0 0..]
how should I code this using plot function in Matlab ? given below:
if(bit==0)
X axis= X++;
Y axis= Y++;
/*graph will show increment by 1 */
else
X axis = X++;
Y axis = Y--;
/* graph will show decrements by 1*/
for example: row 1=[0 0 1...] row 2=[1 0 1...] take row 1 first bit is 0 so point must plot on (1,1) next bit is 0 so point must plot on (2,2) next bit is 1 so plot on(3,1) and so on take row 2 first bit is 1 so plot on (1,-1) next bit is 0 so plot on (2,0) and so on basically 0 show increment by 1 and 1 shows decrements by 1 ... by plotting this type of graph ...it become easy for me to analyse similar pattern of bit strings ...and those bit strings shows similar pattern will be on one cluster..remember X axis is columns and Y axis is rows ..

採用された回答

Guillaume
Guillaume 2016 年 3 月 9 日
bitstrings = [0 0 1 1 0 0 0;
0 1 0 1 0 0 1;
1 0 1 1 1 0 0;
0 1 0 1 0 0 0;] %for example
You need to transform your [0 1] in offsets [+1 -1], which is simply achieve by 1-2*bitstrings. cumsum that and you've got your y coordinates. simply plot that matrix and matlab will use 1:... for x exactly as you want. By default plot plots by columns, so transpose the matrix beforehand:
plot(cumsum(1-2*bitstrings'))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by