How to build imported data function in gnuplot?

If I have a file with multiple data points. How can I build a function from them? For example, suppose I have a column file x and y , and I want to build sin(y) as a 1/x function.

+6
source share
1 answer

Try the following:

 plot "-" u (1/$1):(sin($2)) wl 2.00000 0.16104 3.00000 0.15604 4.00000 0.40055 5.00000 0.09972 e 

Or, if you do not use data files, use the parametric mode, which is described here

EDIT

With this Data.csv data Data.csv :

  0.00000 0.33371 1.00000 0.13034 2.00000 0.16104 3.00000 0.15604 4.00000 0.40055 5.00000 0.09972 6.00000 0.25204 7.00000 -0.34172 8.00000 -0.04733 9.00000 -0.27211 10.00000 0.10229 11.00000 -0.30608 12.00000 0.11006 13.00000 -0.44390 14.00000 -0.16963 15.00000 0.03208 16.00000 0.32431 17.00000 0.15424 18.00000 0.16468 19.00000 0.24410 20.00000 0.34961 

I can run this script:

 f(x) = kappa*x**2 fit f(x) "Data.csv" u (log($1)):(sin($2)) via kappa plot "Data.csv" u 1:(sin($2)), f(x) wl 

What gives me this plot:

Plot of the above script and data file

Of course, fitting makes no sense at all ^^.

Perhaps you are missing the brackets in your form ?!

+6
source

Source: https://habr.com/ru/post/894259/


All Articles