public void Correlate() { if (SelectedSignalCorrelate1 != null && SelectedSignalCorrelate1.HasData() && SelectedSignalCorrelate2 != null && SelectedSignalCorrelate2.HasData()) { SampledSignal signal = new SampledSignal(); signal.PointsY = Correlation.ComputeSignal(SelectedSignalCorrelate1.PointsY, SelectedSignalCorrelate2.PointsY); signal.Name = $"({SelectedSignalCorrelate1.Name})C({SelectedSignalCorrelate2.Name})"; SignalCreator.AddSignal(signal); } }
private void FirstDraw() { ChartSeriesOriginal = new SeriesCollection(); ChartSeriesReceived = new SeriesCollection(); ChartSeriesCorrelate = new SeriesCollection(); ChartValues <double> values = new ChartValues <double>(); ReceivedValues = new ChartValues <double>(); CorrelateValues = new ChartValues <double>(); List <double> pointsY = SelectedSignal.PointsY; List <double> correlateSignal = Correlation.ComputeSignal(SelectedSignal.PointsY, SelectedSignal.PointsY); for (int i = 0; i < pointsY.Count; i++) { values.Add(pointsY[i]); ReceivedValues.Add(pointsY[i]); } for (int i = 0; i < correlateSignal.Count; i++) { CorrelateValues.Add(correlateSignal[i]); } ChartSeriesOriginal.Add(new ScatterSeries() { StrokeThickness = 5, PointGeometry = new EllipseGeometry(), Values = values }); ChartSeriesReceived.Add(new ScatterSeries() { StrokeThickness = 5, PointGeometry = new EllipseGeometry(), Values = ReceivedValues }); ChartSeriesCorrelate.Add(new ScatterSeries() { StrokeThickness = 5, PointGeometry = new EllipseGeometry(), Values = CorrelateValues }); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { S += ObjectV * T; SampledSignal signal = (SampledSignal)SelectedSignal; int samplesToMove = (int)(S / V * signal.Frequency * 2); int samplesLeft = signal.PointsY.Count - samplesToMove; List <double> pointsLeft = signal.PointsY.Take(samplesLeft).ToList(); List <double> receivedSignal = signal.PointsY.Skip(samplesLeft).ToList(); receivedSignal.AddRange(pointsLeft); List <double> correlateSignal = Correlation.ComputeSignal(SelectedSignal.PointsY, receivedSignal); DrawReceived(receivedSignal); DrawCorrelate(correlateSignal); List <double> rightHalf = correlateSignal.Skip((correlateSignal.Count - 1) / 2).ToList(); int maximum = rightHalf.FindIndex(c => c == rightHalf.Max()); CalculatedS = V * (maximum / signal.Frequency) / 2; }