如何在Gnuplot中运行Shell命令并将输出放置在新文件中 [英] How to run a shell command in Gnuplot and place the output in new file

查看:41
本文介绍了如何在Gnuplot中运行Shell命令并将输出放置在新文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Gnuplot:

I have the following Gnuplot:

set encoding iso_8859_1
set key right bottom #font "Helvetica,17" 
set ylabel "Lookup error probability" font "Helvetica,17"
set xlabel "Hight of the reader (m)" font "Helvetica,17"
set xtics font "Helvetica,15"
set ytics font "Helvetica,15"
set size 0.75, 1.05
set terminal postscript eps enhanced color #"Helvetica" 16 #size 3.5in,3in
set grid 
set key spacing 1.5

set output "ProbError6x6.eps"
list(start,end,increment)=system(sprintf("seq %g %g %g", start, increment, end))

system("(awk '(NR>8 ){print; }' Hight_6x6.csv | sed -e 's/[",]/ /g' | sort -nk36) > pe_H_6x6.txt")

set print "pe_H_6x6.dat"
do for [i in list(2,3.5,0.25) ] {
  stats "pe_H_6x6.txt" u ($36==i?($37/$38):1/0) name "A" nooutput
  print i*1, A_mean,   (A_mean - 1.833*A_ssd/sqrt(A_records)),\
    (A_mean + 1.833*A_ssd/sqrt(A_records))
}
plot [][] "pe_H_6x6.dat" using 1:2:3:4 with yerrorlines ls 2 title "6x6 blocks"

具有 system awk 代码的行在我的Gnuplot脚本中不起作用.但是,它可以在unix shell中使用.此代码删除了 Hight_6x6.csv 中的逗号和 ,跳过了前8行,并按第36列的值对结果进行了排序.我无法使其在Gnuplot脚本中工作.CSV文件位于此链接中.

The line with the system and with the awk code does not work in my Gnuplot script. However, it works in the unix shell. This code removes commas and , in Hight_6x6.csv, skips the first 8 lines and sort the result by the values of the 36th column. I cannot make it work in the Gnuplot script. The CSV file is in this link.

推荐答案

您的问题可能是您在命令中包含了双引号:

Your issue is probably that you include a double quote inside the command:

system("(awk '(NR>8 ){print; }' Hight_6x6.csv | sed -e 's/[",]/ /g' | sort -nk36) > pe_H_6x6.txt"
                                                           ^

一种解决方法是使用反引号,例如:

One work-around is to use backquotes, e.g.:

`(awk '(NR>8 ){print; }' Hight_6x6.csv | sed -e 's/[",]/ /g' | sort -nk36 > pe_H_6x6.txt`

或者就像我写的那样:

`tail -n+8 Hight_6x6.csv | tr '",' ' ' | sort -nk36 > pe_H_6x6.txt`

这篇关于如何在Gnuplot中运行Shell命令并将输出放置在新文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆