如何使波德图正常工作?

时间:2015-05-27 20:20:43

标签: c# winforms plot charts axes

我从事控制工程专业学生的申请。它可以绘制步进和脉冲图,计算传递函数,检查对象是否稳定等。我希望它绘制一个波德图,当我尝试这样做时,我就不能设置chart1.ChartAreas[0].AxisX.IsLogarithmic属于true的财产。它捕获异常,图表严重红色。

我认为这个问题是由负值引起的 - 我用非对数刻度绘制它,值从0到-200变化。有没有办法让它正常工作?

      chart1.ChartAreas[0].AxisX.IsLogarithmic = false;
      var series1 = new System.Windows.Forms.DataVisualization.Charting.Series
      {
        ChartType = SeriesChartType.Line
      };
      this.chart1.ChartAreas[0].AxisX.Minimum = 1;
      this.chart1.Series.Add(series1);
      this.chart1.ResetAutoValues();
      for (double i = 1; i < 10; i++) 
      {
        Complex y = TransferFunction.transmitancja_widmowa(i);
        double x = 20 * Math.Log10(y.Magnitude);
        MessageBox.Show(i.ToString());
        if (i > 0)  series1.Points.AddXY(i, x);
      }
      chart1.ChartAreas[0].AxisX.IsLogarithmic = true;
      chart1.Invalidate();

循环结果:     `1.1:-3.44392273685111 1.2:-3.87389826338729 1.3:-4.29752280002408 1.4:-4.71291711058939 1.5:-5.11883360978875 1.6:-5.51449997972875 1.7:-5.89949601325708 1.8:-6.27365856592733 1.9:-6.63700925389649 2:-6.98970004336019 2.1:-7.3319726510657 2.2:-7.664128471124 2.3:-7.98650645445269 2.4:-8.29946695941636 2.5:-8.60338006570994 2.6:-8.89861721258189 2.7:-9.18554530550274 2.8:-9.46452265013073 2.9:-9.73589623427257 3:-10 3.1:-10.2571538390134 3.2:-10.5076631123304 3.3:-10.7518185461869 3.4:-10.9898963940118 3.5:-11.2221587827283 3.6:-11.4488541828714 3.7:-11.6702179579026 3.8:-11.8864729599972 3.9:-12.0978301484852 4:-12.3044892137827 4.1:-12.5066391946324 4.2:-12.7044590801796 4.3:-12.8981183911762 4.4:-13.0877777366472 4.5:-13.2735893438633 4.6:-13.4556975605639 4.7:-13.6342393291718 4.8:-13.809344633307 4.9:-13.981136917305 5:-14.1497334797082 5.1:-14.3152458418745 5.2:-14.4777800929462

5.3:-14.6374372124706 5.4:-14.7943133719774 5.5:-14.9485002168009 5.6:-15.1000851294023 5.7:-15.2491514753987 5.8:-15.3957788334531 5.9:-15.540043210119 6:-15.6820172406699 6.1:-15.8217703768841 6.19999999999999:-15.9593690626917 6.29999999999999:-16.0948768985328 6.39999999999999:-16.2283547952152 6.49999999999999:-16.3598611180083 6.59999999999999:-16.4894518216567 6.69999999999999:-16.6171805769466 6.79999999999999:-16.7430988894148 6.89999999999999:-16.8672562107454 6.99999999999999:-16.9897000433602 7.09999999999999:-17.1104760386703 7.19999999999999:-17.2296280894249 7.29999999999999:-17.3471984165568 7.39999999999999:-17.4632276508995 7.49999999999999:-17.5777549101192 7.59999999999999:-17.6908178711822 7.69999999999999:-17.8024528386535 7.79999999999999:-17.9126948091027 7.89999999999999:-18.0215775318696 7.99999999999999:-18.1291335664285 8.09999999999999:-18.2353943365686 8.19999999999999:-18.3403901815947 8.29999999999999:-18.4441504047382 8.39999999999999:-18.5467033189533 8.49999999999999:-18.6480762902615 8.59999999999999:-18.7482957787972 8.69999999999999:-18.8473873776963 8.79999999999999:-18.9453758499575 8.89999999999999:-19.0422851634008 8.99999999999999:-19.1381385238372 9.09999999999999:-19.232958406555 9.19999999999999:-19.326766586224 9.29999999999998:-19.4195841653081 9.39999999999998:-19.5114316010755 9.49999999999998:-19.6023287312851 9.59999999999998:-19.6922947986264 9.69999999999998:-19.7813484739829 9.79999999999998:-19.8695078785852 9.89999999999998:-19.9567906051162 9.99999999999998:-20.0432137378264`

0 个答案:

没有答案