使用变化的频率和面板分量绘制的简单正弦图. [英] Plot of simple sine graph, using varying frequency and panel component.
问题描述
朋友您好,我是巴西人,如果我的英语有问题,抱歉.我有一个非常基本的问题. ``在C#中的Inciante,我想知道一种绘制正弦图的简单方法,其中可以通过数字上下框来改变图的频率.我正在使用面板执行此任务.谢谢!我要联系的电子邮件为[已删除].
提示
克里斯蒂安诺·德·卡里(Christiano De Carli)
巴西南部-巴西
Hello Friends, I am Brazilian, sorry if my english has some error. I have a very basic question. ''m Inciante in C #, I would like to know a simple way to plot a graph of sine where through a numeric up down box, I can vary the frequency of the graph. I''m using a panel for this task. Thank you! My email to contact is .
Att
Christiano De Carli
Caxias do Sul - Brazil
推荐答案
您可以在此简单函数中使用向上下拉框设置变量,以生成所需频率和采样率的正弦波.
You can use your up down box to set the variables in this simple function to generate a sine wave of the desired frequency and sample rate.
class SineGen
{
public double phaseCnt = 0; // Sample location in sine wave
public double sampleRate = 300; // Number samples in one second
public double freq = 10000; // Desired frequency, Default set to 10Khz
/* Simple Sine Wave Generator
* Make a call to this function for every point
* in the wave form.
*/
public double sineWave()
{
double result = Math.Sin(freq * (2 * Math.PI) * (phaseCnt) / sampleRate);
phaseCnt++;
if (phaseCnt > sampleRate) phaseCnt = 0;
return result;
}
}
在循环或计时器事件中,可以使用以下代码行填充图表控件.
Within the loop or timer event you can populate a chart control using following lines of code.
mySineWave = _SineGen.sineWave();
this.chart1.Series["SineWave"].Points.AddXY(_SineGen.phaseeCnt, mySineWave);
有关图表控件的更多信息,请参见此处: ASP.NET 4.0图表控件 [ ^ ]
祝你好运.
For more on chart controls see here: ASP.NET 4.0 Chart Control[^]
Good luck.
查看以下内容: .NET的灵活图表库 [ ^ ]
Check this out: A flexible charting library for .NET[^]
这篇关于使用变化的频率和面板分量绘制的简单正弦图.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!