0

こんにちは GNUPlot を使って発射体のモーションを作ってみました。

これは私がスクリプトを作成した方法です。最初に y の関数を定義します (y の初期速度はゼロ、x の初期速度は 1、初期垂直位置は yinit =34、初期水平位置はゼロ (原点))。

(効果のない作り方で申し訳ありません、私はここではまったく新しいです)

set term post eps color enhanced font "Times, 24"
set size 1.2, 0.8
set bmargin 3.5

set xlabel "{/Italic x} (m)" font "Times, 30"
set xtics 0 0.5 font "Times, 28"
set mxtics 4
set xrange[0:2.5]

set ylabel "{/Italic y} (m)" font "Times, 30"
set ytics 5 font "Times, 28"
set mytics 2
set yrange [0:40]

set grid xtics ytics mxtics mytics

yinit = 34
vxinit = 1
gr = -9.8
y(t) = yinit + 0.5*gr*t*t 
x(t) = vxinit*t

t = 0.0
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""


t = 0.1
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.2
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.3
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.4
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.5
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.6
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.7
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.8
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.9
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 1.0
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

(まだここに画像を投稿することはできません、まだ評判が低いです)

そして色は青にしたい

4

1 に答える 1

0

パラメトリック プロットが必要です。独立変数のさまざまなステップで (x,y) 位置をプロットします。

yinit = 34
vxinit = 1
gr = -9.8
y(t) = yinit + 0.5*gr*t*t 
x(t) = vxinit*t

set parametric
set trange [0:1]
set samples 11
plot x(t), y(t)  with linespoints pt 7 lc rgb 'blue'

ここに画像の説明を入力

于 2015-03-15T10:32:23.213 に答える