指数图 C# .NET Framework
我从 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 指数后,如下所示: y1expo= A * Math.Pow(e * B*不知道)
e = 2.71828182;
然后将 y1exponential 的值放入图表 1 中。 我是否需要创建第二个 datagridview?,将 x1,y1expo 值放在那里以创建指数样条? 示例: 来源: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: 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:
source: desmos.com
MY PROGRAM:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论