private void ShowFreq() { for (int i = 1; i < 3; i++) { UserControlChart chart = charts[i]; chart.RemoveAll(); chart.Coordinator = new SimpleCoordinator(5, 5, chart.Performer); } Chart.Drawing.Series.SimpleSeries sa = new Chart.Drawing.Series.SimpleSeries(); Chart.Drawing.Series.SimpleSeries sp = new Chart.Drawing.Series.SimpleSeries(); freqstep = maxfreq / 400; double maxamp = 0; double coeff = clone.HighFrequecyCoefficient; int max = 0; for (int i = 0; ; i++) { ++max; if (max > 10000) { break; } double a = (double)i * freqstep; double amp; double ph; clone.GetFrequencyCharacteristics(a, out amp, out ph); if (a > maxfreq & ((Math.Abs(amp - coeff) < 0.01 * Math.Abs(maxamp - coeff)) | amp > maxamp)) { break; } if (amp > maxamp) { maxamp = amp; } sa.AddXY(a / (2 * Math.PI), amp); sp.AddXY(a / (2 * Math.PI), 180 * ph / Math.PI); } Chart.Drawing.Series.SimpleSeries[] ss = new Chart.Drawing.Series.SimpleSeries[] { sa, sp }; for (int i = 0; i < 2; i++) { charts[i + 1].AddSeries(ss[i], Color.Red); } }
private void ShowLog() { if (clone == null) { return; } for (int i = 1; i < 3; i++) { UserControlChart chart = charts[i]; chart.RemoveAll(); LogarithmCoordinator coord = new LogarithmCoordinator(chart.Performer); coord.LogX = true; if (i == 1) { coord.LogY = true; } chart.Coordinator = coord; } double ml = Math.Log10(maxfreq); //double step = ml / 400; Chart.Drawing.Series.SimpleSeries sa = new Chart.Drawing.Series.SimpleSeries(); Chart.Drawing.Series.SimpleSeries sp = new Chart.Drawing.Series.SimpleSeries(); double dec = 100; double minlog = -3; if (minfreq > 0) { minlog = Math.Log10(minfreq); } double step = Math.Log10(dec) / 400; double logpi = Math.Log10(2 * Math.PI); double maxamp = 0; double coeff = clone.HighFrequecyCoefficient; int max = 0; for (int i = 1; ; i++) { ++max; if (max > 10000) { break; } double x = (double)i * step + minlog; double f = Math.Pow(10, x); double amp; double ph; clone.GetFrequencyCharacteristics(f, out amp, out ph); if (amp > maxamp) { maxamp = amp; } if (f > maxfreq & ((Math.Abs(amp - coeff) < 0.01 * Math.Abs(maxamp - coeff)) | amp > maxamp)) { break; } amp = Math.Log10(amp); double fr = x - logpi; sa.AddXY(fr, amp); sp.AddXY(fr, 180 * ph / Math.PI); } Chart.Drawing.Series.SimpleSeries[] ss = new Chart.Drawing.Series.SimpleSeries[] { sa, sp }; for (int i = 0; i < 2; i++) { charts[i + 1].AddSeries(ss[i], Color.Red); } }