1

I want to use the plot for feature in gnuplot to plot functions with varying parameters. Here an example

par = "1 2" #two values for the parameter
f(x,a) = sin(a*x)
g(x,a) = cos(a*x)
plot for [i=1:words(par)]  g(x, word(par,i)), f(x, word(par,i))

What I expect is the plotting of the four functions g(x,1), g(x,2, f(x,1), and f(x,2).

But for whatever reason only three functions are plotted, namely: g(x,1), g(x,2, and f(x,2).

This seems completely arbitrary to me.

Can someone help me out?

1 Answer 1

1

You have to repeat the for condition:

plot for [i=1:words(par)]  g(x, word(par,i)), for [i=1:words(par)] f(x, word(par,i))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.