指数图 C# .NET Framework

发布于 2025-01-18 14:42:00 字数 1811 浏览 0 评论 0原文

我从 datagridview1 中提取值来计算指数方程。

foreach (DataRow pr in Global_var.data_source.Tables[0].Rows)
{
    try
    {
        x1 = (double)pr[0];
        y1 = (double)pr[1];
        chart1.Series[1].Points.AddXY(x1, y1);
        chart1.Series[1].ChartType = SeriesChartType.Spline;
    }
    catch
    {
        x1 = 0;
        y1 = 0;
        MessageBox.Show("");
    }
} 

int number_of_rows = Global_var.data_source.Tables[0].Rows.Count;

foreach (DataRow pr in Global_var.data_source.Tables[0].Rows)
{
    xpriemer += (double)pr[0];
    lny *= (double)pr[1];
    sxy += (double)pr[0] *Math.Log((double)pr[1]);
    sxx += (double)pr[0] * (double)pr[0];
    syy += Math.Log((double)pr[1]) * Math.Log((double)pr[1]);
}        

xpriemer /= (double)number_of_rows;
xpriemer = Math.Round(xpriemer, 4);
/////////////
lny = Math.Round(lny, 4);
lnyc = Math.Log(lny) / (double)number_of_rows;
lnyc = Math.Round(lnyc, 4);
//////////
sxyc = sxy - (number_of_rows * xpriemer * lnyc);
sxyc = Math.Round(sxyc, 4);
///////////
sxxc = sxx - (number_of_rows * xpriemer * xpriemer);
sxxc = Math.Round(sxxc, 4);
///////////
B = sxyc / sxxc;
B = Math.Round(B, 4);
//////////
A = Math.Exp(lnyc - B * xpriemer);
A = Math.Round(A, 4);
////////////////
syyc = syy - number_of_rows * lnyc * lnyc;
///////
r = (sxyc / (Math.Sqrt(sxxc) * Math.Sqrt(syyc)));
r2 = sxyc * sxyc / (sxxc * syyc);

在我需要计算 X1 列中每一行的 Y1 指数后,如下所示:equation y1expo= A * Math.Pow(e * B*不知道)

e = 2.71828182;

然后将 y1exponential 的值放入图表 1 中。 我是否需要创建第二个 datagridview?,将 x1,y1expo 值放在那里以创建指数样条? 示例: example 来源:desmos.com

我的程序:
我的程序

I extracted values from datagridview1 to calculate an exponential equation.

foreach (DataRow pr in Global_var.data_source.Tables[0].Rows)
{
    try
    {
        x1 = (double)pr[0];
        y1 = (double)pr[1];
        chart1.Series[1].Points.AddXY(x1, y1);
        chart1.Series[1].ChartType = SeriesChartType.Spline;
    }
    catch
    {
        x1 = 0;
        y1 = 0;
        MessageBox.Show("");
    }
} 

int number_of_rows = Global_var.data_source.Tables[0].Rows.Count;

foreach (DataRow pr in Global_var.data_source.Tables[0].Rows)
{
    xpriemer += (double)pr[0];
    lny *= (double)pr[1];
    sxy += (double)pr[0] *Math.Log((double)pr[1]);
    sxx += (double)pr[0] * (double)pr[0];
    syy += Math.Log((double)pr[1]) * Math.Log((double)pr[1]);
}        

xpriemer /= (double)number_of_rows;
xpriemer = Math.Round(xpriemer, 4);
/////////////
lny = Math.Round(lny, 4);
lnyc = Math.Log(lny) / (double)number_of_rows;
lnyc = Math.Round(lnyc, 4);
//////////
sxyc = sxy - (number_of_rows * xpriemer * lnyc);
sxyc = Math.Round(sxyc, 4);
///////////
sxxc = sxx - (number_of_rows * xpriemer * xpriemer);
sxxc = Math.Round(sxxc, 4);
///////////
B = sxyc / sxxc;
B = Math.Round(B, 4);
//////////
A = Math.Exp(lnyc - B * xpriemer);
A = Math.Round(A, 4);
////////////////
syyc = syy - number_of_rows * lnyc * lnyc;
///////
r = (sxyc / (Math.Sqrt(sxxc) * Math.Sqrt(syyc)));
r2 = sxyc * sxyc / (sxxc * syyc);

After I need to calculate Y1exponential for every row in column X1 like shown here:equation y1expo= A * Math.Pow(e * B*idontknow)

e = 2.71828182;

And then put the values for y1exponential to chart1.
Do i need to create a second datagridview?, to put the x1,y1expo values there to create and exponential spline?
EXAMPLE:
example source: desmos.com

MY PROGRAM:
my program

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文