Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用gnuplot不准确地绘制分段线性函数_Gnuplot - Fatal编程技术网

用gnuplot不准确地绘制分段线性函数

用gnuplot不准确地绘制分段线性函数,gnuplot,Gnuplot,我在用gnuplot绘制分段线性函数h(x)=max(0,1-| x |)(hat函数)时遇到了一个问题。我的目标是展示使用这些帽函数作为基函数的多项式插值。因此,我需要将它们移动并缩放到不同的网格点 我的代码如下所示: set key inside bottom right set xrange [0:1] set yrange [0:6] set grid xtics set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth

我在用gnuplot绘制分段线性函数h(x)=max(0,1-| x |)(hat函数)时遇到了一个问题。我的目标是展示使用这些帽函数作为基函数的多项式插值。因此,我需要将它们移动并缩放到不同的网格点

我的代码如下所示:

set key inside bottom right
set xrange [0:1]
set yrange [0:6]
set grid xtics
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2
set ytics 1
set xtics 2**(-3)
set key right top
s(x) = (3.0 * x - 1)
a0 = 2
a1 = -6
a2 = 5
a3 = 5
a4 = -5
a5 = 1
f(x) = a0 + a1*s(x) + a2*(s(x)**2) + a3*(s(x)**3) + a4*(s(x)**4) + a5*(s(x)**5)
max(x, y) = (x > y) ? x:y
h(x) = max(0, 1 - abs(x))
nodal(x, i)=h(2**(3)*x - i) * f(i * 2**(-3))

plot f(x) title "f(x)", nodal(x, 1)
但是,输出如下所示:


显然,对于节点基函数不可微的点,它无法很好地绘制函数,这看起来很糟糕。因为我想把这篇论文包括在我必须提交的论文中,所以我不能把它包括在内。这个问题有什么解决办法吗?

设置10000个样本
谢谢,为我解决了这个问题!