本文介绍了bash:将保存的变量加载到gnuplot cmd加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意图是在循环中加载变量i-我想使其在此循环中可用.当前状态是gnuplot从第一个回显中将var i作为字符串而不是var加载.

My intention is to have loaded variable i in for cycle - I want to have it usable for this cycle. Current state is that gnuplot loads var i from the first echo as a string not var.

SPEED=5

echo "plot '< head -n \"\$((SPEED*i))\" `echo ${INFILE}`' using 1:3 ;">> file.plt

for ((i=1;i<="$FRAMES";i++))
do
    echo  "
        load '`echo ${file.plt}`';
        " | gnuplot
done

推荐答案

我认为您可以直接在gnuplot中完成所有这些操作...

I think you can probably do all of this in gnuplot directly...

if(! exists("N")) N=0
FRAMES=10
FILE='myfile.plt'
SPEED=5
f(i)=sprintf("< head -n %d ".FILE,i+SPEED)
plot f(N) using 1:3
if(N < FRAMES) N=N+1
if(N < FRAMES) reread


Gnuplot 4.6使这变得更加容易:


Gnuplot 4.6 makes this even easier:

do for [N=1:10]{
   FILE='myfile.plt'
   SPEED=5
   f(i)=sprintf("< head -n %d ".FILE,i+SPEED)
   plot f(N) using 1:3

}

,而不是使用head,您可能可以使用every数据文件修饰符(有关详细信息,请参见help every).我认为是这样的:

and instead of using head, you can probably use the every datafile modifier (help every for details). I think something like the following:

NPT=N+SPEED
plot FILE every ::::NPT using 1:3

这篇关于bash:将保存的变量加载到gnuplot cmd加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:07