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 回答