0

I want to plot this parametric funtion

 x(t)=a+(n/w)*(cos(w*t)-1)-((g/w**2)*sin(l)-m/w)*(sin(w*t)+(g*t/w)*sin(l))

 y(t)=b+((g/w**2)*sin(l)-m/w)*(cos(w*t)-1)+(n/w)*sin(w*t)  

But I have various parameters a,b,m,n,w,k,g y I want to vary a,b,m,n,w,k parameters. g=7

I don't know how do it.

However i intended:

plot for [a=1:0],[b=1:0],[n=0:1],[m=1:0],[g=7:7],[w=2*pi*3:2*pi*2] x(t),y(t)

I appreciate your help. thanks!

PCat27
  • 33
  • 1
  • 7
  • 1
    Last term in `y(t)` should be `sin(w*t)` please [edit] – gboffi Dec 09 '17 at 14:47
  • 1st issue, the parameters that you have used in the definitions are `a, b, g, l, m, n, w` — you haven;t named `l` in the question but you have introduced a spurious `y` that is not a parameter nut a dependent variable, please [edit] ፨ 2nd issue, you have a loop for `w` in which the required step is not defined... would you like a step of `pi`? of `pi/2`? of `2*pi`? please [edit] the question – gboffi Dec 09 '17 at 15:25

1 Answers1

2

For what regards multiple for in a single plot command, the syntax is documented in the inline help of gnuplot

 Nested iteration is supported:

       set for [i=1:9] for [j=1:9] label i*10+j sprintf("%d",i*10+j) at i,j

E.g.,

gnuplot> plot for[a=0:1] for[b=0:1] 1+a*x+b*x*x

plot for[a=0:1] for[b=0:1] 1+a*x+b*x*x


You could do now what you want except for a further problem: in gnuplot numeric loops variables have only integer values, e.g.,

gnuplot> plot for [s=3.2:9.3:2.9] x title sprintf("%f", s)

plot for [s=3.2:9.3:2.9] x title sprintf("%f", s)

so your loop on w is impossible, you have to devise a different strategy.

With the provision that I don't know what value you want to assign to l (I've used l=1) and also that I don't know the step on w, here it is a possible implementation where the tricks are ❶ define a function that gives you the values of w in terms of an integer variable and ❷ define x and y also in terms of this auxiliary variable

gnuplot> set parametric
gnuplot> w(k) = 2*pi*k
gnuplot> x(t, k)=a+(n/w(k))*(cos(w(k)*t)-1)-((g/w(k)**2)*sin(l)-m/w(k))*(sin(w(k)*t)+(g*t/w(k))*sin(l))
gnuplot> y(t, k) = b + ((g/w(k)**2)*sin(l)-m/w(k))*(cos(w(k)*t)-1)+(n/w(k))*sin(w(k)*t)
gnuplot> g = 7 ; l = 1
gnuplot> plot for[a=0:1] for[b=0:1] for[m=0:1] for[n=0:1] for[k=2:3] x(t,k), y(t,k) title sprintf("%d,%d,%d,%d,%d", a,b,n,m,k)

strange plots

gboffi
  • 22,939
  • 8
  • 54
  • 85