小编gma*_*man的帖子

ScateredInterpolant() 的线性外推法在 MATLAB 中如何工作?

对于我的项目,我必须编写 C++ 代码,相当于 Matlab 的 ScatteredInterpolant() 函数。我的数据点是三维的分散数据。我可以使用 TetGen 库计算 Delaunay 四面体。我使用从 TetGen 和 Matlab 自己的 delaunay() 函数找到的四面体比较了插值结果,只要查询点位于凸包内,结果就相同。

在我的项目中,我必须使用线性外推法来外推凸包之外的点。我浏览了 Matlab 文档,它说“基于边界梯度的线性外推”。从我的文献调查中,我找不到很好的文档来说明线性外推如何使用边界梯度进行工作。如果您向我提供有关分散插值()的线性外推如何工作的见解,我将非常感激。

我查看了分散数据外推文档页面,其中写着“‘线性’外推方法基于凸包边界处梯度的最小二乘近似。它为凸包之外的查询点返回的值凸包基于边界处的值和梯度。” 为了验证,我编写了以下代码(2D数据):

clc;clear;close all;

x = [ -1 1 1 -1 0 ]; y = [ -1 -1 1 1 0 ];

v = x.^2 + y.^2;

tri = delaunay(x, y);

F = scatteredInterpolant(x(:), y(:), v(:), 'linear', 'linear');

[xq, yq] = meshgrid( -2 : 0.1 : 2 );

vq = F(xq, yq);

figure; plot(x, y, 'r*');hold on; tri = delaunay(x, …
Run Code Online (Sandbox Code Playgroud)

c++ matlab extrapolation

5
推荐指数
0
解决办法
1034
查看次数

c ++模板构造函数的问题

码:

#include<iostream>

using namespace std;

template<class T, int N> class point {
    T coordinate[N];
public:
    point(const point<T,N>&);
    const double& operator[](int i) const {
        return coordinate[i];
    }
};

template<class T, int N> point<T,N>::point(const point<T,N>&p)
{
    for(int i=0;i<N;i++)
        coordinate[i]=p.coordinate[i];
};

int main() {
    point<int,2> P2;
    point<double,3> P3;
    cout<<P2[0]<<P3[1];
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

prog.cpp: In function ‘int main()’:
prog.cpp:17: error: no matching function for call to ‘point<int, 2>::point()’
prog.cpp:11: note: candidates are: point<T, N>::point(const point<T, N>&) [with T =
             int, int N = …
Run Code Online (Sandbox Code Playgroud)

c++ templates constructor

4
推荐指数
1
解决办法
1857
查看次数

C++运算符重载错误

#include<iostream>
using namespace std;

class complex {
    double real;
    double image;
public:
    complex(double r=0,double i=0) : real(r), image(i) { };
    complex(const complex& c) : real(c.real), image(c.image) { };
    ~complex(){};
    double re() const {
        return real;
    };
    double im() const{
        return image;
    };
    const complex& operator =(const complex&c)
    {
        real = c.real;
        image = c.image;
        return *this;
    };
    const complex& operator +=(const complex&c)
    {
        real += c.real;
        image += c.image;
        return *this;
    };
    const complex& operator -=(const complex&c)
    {
        real -= …
Run Code Online (Sandbox Code Playgroud)

c++ overloading operator-keyword

0
推荐指数
2
解决办法
7702
查看次数

在c程序文件中运行cmd命令

这里出了问题:

假如我想在cmd中运行plot.exe,我在cmd中编写了以下行,

plot image.jpg

顺便说一句,我在我的c文件中尝试这种方式:

system("start plot image.jpg")

上面的命令启动cmd和plot命令,但图像文件没有弹出.有一个错误命令:

"image.jpg不是def"

这是什么意思?请帮帮我.

c

0
推荐指数
1
解决办法
6260
查看次数