データの配列(具体的にはベクトル)があると仮定します。モニターを通してトレースされている実際の信号のように見えるように、Gnuplotを使用して要素ごとに順番にプロットできますか?
Common Lispを使用してデータ全体をテキストファイルに書き込み、gnuplotを使用してバッチ形式でプロットできることを知っています。私が必要としているのは、データが順番に来るので、プロットにポイントを置きたいということです。
データはおそらくループ内で生成されるため、x軸を整数値の離散時間軸と見なすことができます。したがって、ループ内で配列の最初の要素が5として生成された場合、プロット上に(0,5)にポイントを設定したいと思います。次に、2番目の要素が3として生成された場合、プロットに別のポイントを(1,7)に配置します(古いデータポイントを保持します)。したがって、ループを反復処理しながら、データを順番にプロットします。
私は目的のためにemacsとCommonLispを使用しており、これらのツール内にとどまるこのデータをプロットしたいと思います。gnuplot以外に選択肢があれば聞いてみたいです。
これが簡単に不可能な場合は、CommonLispコマンドでGnuplotコマンドファイルを実行できればすばらしいでしょう。
編集:
cgn
このスレッドの下で人々が与えたアドバイスに従って、私はを使用してコードを書きましたltk
。
今、画面の事前に指定された位置で2つのx11ウィンドウを開き、ループに入ります。ストリームを開くたびにループで、オプションを指定してデータ(0.25Hzの正弦波と余弦波を20Hzでサンプリング)をテキストファイルtrial.txtに書き込み:if-exists :append
、ストリームを閉じます。次に、各反復で、format-gnuplot
コマンドを介してgnuplotを使用してデータ全体をプロットします。このコードは、事前に指定されたxおよびy範囲の2つのウィンドウを提供し、ウィンドウ内の前述の正弦波と余弦波の進化を見ることができます。
私が前に述べたように、私は強力なプログラミングのバックグラウンドを持っておらず(私はどういうわけか一般的なlispの使用をやめた電気技師です)、私のコードは最適ではなく、不法であると確信しています。アドバイスや訂正などがありましたら、ぜひお聞かせください。コードはここにあります:
(setf filename "trial.txt")
(setf path (make-pathname :name filename))
(setf str (open path :direction :output :if-exists :supersede :if-does-not-exist :create))
(format str "~,4F ~,4F" -1 -1)
(close str)
;start gnuplot process
(start-gnuplot "/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot")
;set 2 x11 windows with the following properties
(format-gnuplot "cd ~S" "Users/yberol/Desktop/lispbox/code")
(format-gnuplot "set terminal x11 0 position 0,0")
(format-gnuplot "set xrange [0:10]")
(format-gnuplot "set yrange [-1:1]")
(format-gnuplot "unset key")
(format-gnuplot "set grid")
(format-gnuplot "plot ~S using 1" filename)
(format-gnuplot "set terminal x11 1 position 800,0")
(format-gnuplot "plot ~S using 2" filename)
;write data into text
(loop :for i :from 0 :to 10 :by (/ 1 20) :do
(setf str (open path :direction :output :if-exists :append :if-does-not-exist :create))
(format str "~,4F ~,4F ~,4F ~%" i (sin (* 2 pi (/ 5 20) i)) (cos (* 2 pi (/ 5 20) i)))
(close str)
(format-gnuplot "set terminal x11 0")
(format-gnuplot "plot ~S using 1:2 with lines" filename)
(format-gnuplot "set terminal x11 1")
(format-gnuplot "plot ~S using 1:3 with lines" filename)
(sleep 0.1))
(close-gnuplot)
どうもありがとうございます。