Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #2556
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ethan A Merritt <sfeam@users.sourceforge.net> |
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: difficult for loop synax :-| |
| Date | Wed, 20 Aug 2014 10:15:51 -0700 |
| Organization | gnuplot development |
| Lines | 54 |
| Message-ID | <lt2l49$hgn$1@dont-email.me> (permalink) |
| References | <9bc28e9e-f776-4407-8acc-f0bc7a964bcf@googlegroups.com> <lt0s51$jbh$1@dont-email.me> <7d92eab8-bceb-49bb-80aa-ff7834bc9a73@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| Injection-Date | Wed, 20 Aug 2014 17:15:53 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="8e86a57dfa599721f116da4577f3d1af"; logging-data="17943"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+piWX6kPbAdVkLrkLbH2op" |
| User-Agent | KNode/4.10.5 |
| Cancel-Lock | sha1:roXeWF0SlqtmPkWPW4nWhh/hYPA= |
| Xref | csiph.com comp.graphics.apps.gnuplot:2556 |
Show key headers only | View raw
Kalin Kozhuharov wrote:
> On Wednesday, August 20, 2014 10:03:27 AM UTC+9, Ethan A Merritt wrote:
>> Kalin Kozhuharov wrote:
>> > I have been trying to plot two dependent functions per single for
>> > loop, but cannot get the syntax right...
>> > This works but is a lot of typing and if I don't know the number of
>> > arguments cannot be expressed:
>>
>> > plot C=1, sin(C*x) w l, C=2, sin(C*x) w l, C=3, sin(C*x) w l;
>>
>> Please clarify. I see only a single function there, evaluated
>> three times. Where is the second dependent function?
>>
> Well, may be I oversimplified it, but the real thing is too complex
> anyway. What about this:
>
> reset; f1(x) = (C=1.134324*x,0); f2(x) = sin(C*x); set xrange [0:3.14];
> plot a=f1(1), f2(x) title "n=1", a=f1(2), f2(x) title "n=2" , a=f1(3),
> f2(x) title "n=3";
It is still not clear what you are aiming for.
The sequence of commands above does not make sense.
The function f1(x) is never plotted, so it plays no role except for
its side effect of setting C to a constant.
A simpler way to write it would be
f1(x) = 1.134324*x
plot for [n=1:3] sin(f1(n)*x) title sprintf("n=%d",n)
> How can I turn it into something like:
> N="1 2 3"; plot for [n in N] a=f1(n), f2(x) title "n=" . n;
> when I don't know N
Same as above, replacing 3 with N
plot for [n=1:N] ...
Of course N still has to come from somewhere, I assume from some
earlier part of the script.
> so that it produces the same result (all plots on same graph,
> automatically linestyled) when I don't know N. Currently this produces
> only one graph when n=3, because the for loop is only evaluated till the
> ",", then f2(x) is plotted once. I need some kind of syntactic "brackets".
>
> I also tried:
> N="1 2 3"; do for [n in N] {plot a=f1(n), f2(x) title "n=" . n; pause .2;
> }; and saw how the plot is being generated, then overwritten by the next
> call of plot.
>
> Cheers,
> Kalin.
--
Ethan A Merritt
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-19 11:57 -0700
Re: difficult for loop synax :-| Ethan A Merritt <EAMerritt@gmail.com> - 2014-08-19 18:03 -0700
Re: difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-19 23:15 -0700
Re: difficult for loop synax :-| Ethan A Merritt <sfeam@users.sourceforge.net> - 2014-08-20 10:15 -0700
Re: difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-20 11:50 -0700
Re: difficult for loop synax :-| Ethan A Merritt <EAMerritt@gmail.com> - 2014-08-20 17:50 -0700
Re: difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-20 23:02 -0700
csiph-web