Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #1854
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | sfeam <sfeam@users.sourceforge.net> |
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: Defining multiple similar functions, and fitting them, using a for loop |
| Followup-To | comp.graphics.apps.gnuplot |
| Date | Thu, 23 May 2013 15:34:33 -0700 |
| Organization | gnuplot development team |
| Lines | 70 |
| Message-ID | <knm5a5$oi0$1@dont-email.me> (permalink) |
| References | <52d92c72-a809-490f-86e9-c577132ffa44@googlegroups.com> <eee78761-c914-4658-86b1-c10ee0fa56e8@googlegroups.com> |
| Reply-To | sfeam@users.sourceforge.net |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| Injection-Date | Thu, 23 May 2013 22:30:29 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="8e86a57dfa599721f116da4577f3d1af"; logging-data="25152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sRweJpdN4nKwOpu9M9IiD" |
| User-Agent | KNode/4.4.9 |
| Cancel-Lock | sha1:1cVUi72KcdO6vsjJ52QE9khZZ7I= |
| Xref | csiph.com comp.graphics.apps.gnuplot:1854 |
Followups directed to: comp.graphics.apps.gnuplot
Show key headers only | View raw
kress.florian@gmail.com wrote: > On Thursday, March 14, 2013 6:34:10 PM UTC+1, Thomas Grant wrote: >> Dear all, >> >> First, I would like to fit all the data files to a function: >> >> f1(x)=m1*x+b1 >> >> f2(x)=m2*x+b2 >> >> etc... >> >> >> then I'd like to fit them: >> >> fit f1(x) 'datafile_1.dat' via m1,b1 >> >> etc.... >> >> >> then I'd like to plot the data files, which I can do with a for loop: >> >> >> plot for [i=1:8] 'datafile_'.i.'.dat' >> >> >> however, I'd also like to plot the fits, which doesn't seem to work with >> a for loop. I've tried the following (after individually defining f1(x), >> f2(x), etc...): >> >> >> >> plot for [i=1:8] fi(x) >> >> plot for [i=1:8] f.i.(x) >> >> plot for [i=1:8] j=i fj(x) >> >> plot for [i=1:8] j=i f.j.(x) >> >> plot for [i=1:8] j=i "f".j."(x)" >> >> >> >> and none of these seem to work. I don't have an answer for handling an unbounded number of previously unknown functions, but for some reasonable number, say 10 or so, you can create a little pre-definition script that maps fi(x) onto g(i,x) g(i,x) = \ i == 1 ? f1(x) : \ i == 2 ? f2(x) : \ i == 3 ? f3(x) : \ i == 4 ? f4(x) : \ i == 5 ? f5(x) : \ i == 6 ? f6(x) : \ i == 7 ? f7(x) : \ i == 8 ? f8(x) : \ i == 9 ? f9(x) : \ i == 10 ? f10(x) : \ NaN Now your plot command is plot for [i=1:8] g(i,x) Ethan
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Find similar | Unroll thread
Defining multiple similar functions, and fitting them, using a for loop Thomas Grant <tomer485@gmail.com> - 2013-03-14 10:34 -0700
Re: Defining multiple similar functions, and fitting them, using a for loop Karl <mail.kfr@gmx.net> - 2013-03-15 08:49 +0100
Re: Defining multiple similar functions, and fitting them, using a for loop Karl <mail.kfr@gmx.net> - 2013-03-15 08:59 +0100
Re: Defining multiple similar functions, and fitting them, using a for loop Karl <mail.kfr@gmx.net> - 2013-03-15 14:45 +0100
Re: Defining multiple similar functions, and fitting them, using a for loop Karl <mail.kfr@gmx.net> - 2013-03-15 16:50 +0100
Re: Defining multiple similar functions, and fitting them, using a for loop sfeam <sfeam@users.sourceforge.net> - 2013-03-15 11:52 -0700
Re: Defining multiple similar functions, and fitting them, using a for loop kress.florian@gmail.com - 2013-05-23 13:03 -0700
Re: Defining multiple similar functions, and fitting them, using a for loop sfeam <sfeam@users.sourceforge.net> - 2013-05-23 15:34 -0700
csiph-web