几何尺寸与公差论坛

 找回密码
 注册
查看: 630|回复: 1

翘曲晶圆的插补

[复制链接]
发表于 2023-5-25 15:45:38 | 显示全部楼层 |阅读模式
使用MathNet.Numerics库中的Fit.Polynomial方法对一组数据进行二次多项式拟合之后,然后给任意一个x,求出拟合线对应的y,用c#编写

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2023-5-25 15:46:14 | 显示全部楼层
using MathNet.Numerics;
using MathNet.Numerics.LinearAlgebra;

class Program
{
    static void Main(string[] args)
    {
        // 定义数据
        double[] x = { 1, 2, 3, 4, 5 };
        double[] y = { 2.1, 3.9, 7.2, 12.5, 20.1 };

        // 定义二次多项式的阶数
        int order = 2;

        // 进行拟合
        Vector<double> coefficients = Fit.Polynomial(x, y, order);

        // 定义任意一个x值
        double xValue = 3.5;

        // 计算拟合线对应的y值
        double yValue = 0;
        for (int i = 0; i < coefficients.Count; i++)
        {
            yValue += coefficients[i] * Math.Pow(xValue, i);
        }

        Console.WriteLine("拟合线在x={0}处的y值为:{1}", xValue, yValue);
    }
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-5-7 04:07 , Processed in 0.039471 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表