2016-09-07 2 views
0

階段を使用してバイナリ入力をプロットしようとしていますが、データがゼロから始まらない。どのようにプロットを作るかは、1つではなくゼロから始めるのですか?Matlab階段プロットが起点から始まらない

MATLABコード:

a = [ 0 0 1 0 1 0 0 1 0 1 1 1 1 1 ]; 
stairs(a); 
axis([0 14 -0.5 1.5 ]); 
grid on; 

答えて

0

あなたは、あなたのデータは、x軸上で起動場所を明確にするためには、Xベクトルを追加する必要があります。 plot commandのヘルプを見てとる

y = round(rand(1,10)); %binary vector 
x = [0:length(y)-1]; %[0,1,2,3,4....] 
stairs(x,y); 
axis([0,10,-0.5,1.5]) 
0

プロット(Y)は 各値のインデックスに対してYのデータの2-D線プロットを作成します。 Y.

の行

If Y is a vector, then the x-axis scale ranges from 1 to length(Y). 

    If Y is a matrix, then the plot function plots the columns of Y versus their row number. The x-axis scale ranges from 1 to the 

If Y is complex, then the plot function plots the imaginary part of Y versus the real part of Y, such that plot(Y) is equivalent to 

プロット(REAL(Y)、IMAG(Y))。ゼロから始まるプロットする

: ベクター:プロット(0:長さ(Y) - 1、y)は 行列:プロット(0:サイズ(M、1) - 1、M)

階段にも同じことが言えます。簡単に0から始める簡単な方法は、簡単に次のようにプロットにx軸を追加することです:

>> stairs(0:length(a)-1,a),axis([0 14 -0.5 1.5 ]);grid on; 
関連する問題