private void CALCULATE_OUTPUT_Click(object sender, RoutedEventArgs e) { //Parsowanie wprowadzonych wspolczynnikow i zapis do odpowiednich zmiennych if (CheckData()) { MessageBox.Show("Podaj prawidłowe współczynniki!"); } else { InOut inOutData = new InOut(); inOutData = CalculateOutput(); DrawChart(inOutData.getInput(), chart_2, InputChart_Color); DrawChart(inOutData.getOutput(), chart_1, OutputChart_Color); } }
private InOut CalculateOutput() { // Inicjalizacja zmiennych InOut inOutData = new InOut(); // Zerowe warunki początkowe double y3_prev = 0; double y2_prev = 0; double y1_prev = 0; double y_prev = 0; double y3_current = 0; double y2_current = 0; double y1_current = 0; double y_current = 0; double t = 0; for (int i = 0; i < (tmax * 1030); i++) { t = i * integration_step; y3_current = InputValue(t) - A * y2_prev - B * y1_prev - ValueOfCt(t) * y_prev; y2_current += Integral(y3_prev, y3_current); y1_current += Integral(y2_prev, y2_current); y_current += Integral(y1_prev, y1_current); if (i % tmax == 0) { inOutData.AddInput(InputValue(t)); inOutData.AddOutput(y_current); } y3_prev = y3_current; y2_prev = y2_current; y1_prev = y1_current; y_prev = y_current; } return(inOutData); }