Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #1423
| Newsgroups | comp.graphics.apps.gnuplot |
|---|---|
| Date | 2012-10-21 13:59 -0700 |
| References | <0665cef1-fa95-4d16-aa5f-8030d8674cb7@googlegroups.com> |
| Message-ID | <d4827748-d3e5-48d3-9acd-20a84f965159@googlegroups.com> (permalink) |
| Subject | Re: accesssing shell array variable with a gnuplot loop index |
| From | fh.faraz.hussain@gmail.com |
Hello,
I got this to work by using "${var[*]}":
http://unix.stackexchange.com/questions/52453/gnuplot-shell-variable-substitution-and-arrays
Best
Faraz
On Saturday, October 20, 2012 10:22:33 PM UTC-4, fh.faraz...@gmail.com wrote:
> Hello all,
>
>
>
> I need to use shell variables in my gnuplot commands, for which I'm using the here document style. I also need to use loops inside the gnuplot code. Both these things are working.
>
>
>
> Now -- I want to use a gnuplot for loop's index to access a shell array variable. This is where I've been stuck all day.
>
>
>
> I have something like this:
>
>
>
> for ((i=0; i<=10; i++))
>
> do
>
> var[$i] = i*10
>
> done
>
>
>
> gnuplot<<EOF
>
> do for [j=1:10]{
>
> #need to access ${var[j]} somehow
>
> val=sprintf("${var[%d]", j) ##doesn't work
>
> }
>
> EOF
>
>
>
> (Individual access like ${var[1]} works.)
>
>
>
> I thought of first storing the *name* of the shell variable somewhere and then dereferencing it (using $), but didn't work.
>
>
>
> I suspect this may need using backquotes and/or expr, but am not sure. The manual mentions the 'value' command which seems to be what would be required here, but I couldn't get it to work. The 'evaluate' command also looks relevant. I have been reading the bash and gnuplot manuals -- have learned a lot the past few hours, but couldn't solve the problem.
>
>
>
>
>
> Best
>
> Faraz
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Find similar
accesssing shell array variable with a gnuplot loop index fh.faraz.hussain@gmail.com - 2012-10-20 19:22 -0700 Re: accesssing shell array variable with a gnuplot loop index fh.faraz.hussain@gmail.com - 2012-10-21 13:59 -0700
csiph-web