RK using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Obwod_Z.Banasiak { public partial class Form1 : Form { double E = 10, R = 1, C = 10E-3; public Form1() { InitializeComponent(); } double f(double t, double uC) { return (E - uC) / (R * C); } private void button1_Click(object sender, EventArgs e) { double t, h = 2E-3; double uCs, uCn; t = 0; uCs=0; double k1 = h * (t + uCs); double k2 = h * (t + h / 2 + uCs + k1 / 2); double k3 = h * (t + h / 2 + uCs + k2 / 2); double k4 = h * (t + h + uCs + k3); do { //wzorzec chart1.Series[0].Points.AddXY(t, E*(1-Math.Exp(-t/(R*C)))); //Eulera chart1.Series[1].Points.AddXY(t, uCs); // przebieg pr?du chart1.Series[3].Points.AddXY(t, C*f(t,uCs)); //Rungego-Kutty IV chart1.Series[2].Points.AddXY(t, (0.5+uCs + (k1 + 2 * k2 + 2 * k3+k4) / 6)); uCn = uCs + h * f(t, uCs); uCs = uCn; t +=h; } while (t<=80E-3); } private void Form1_Load(object sender, EventArgs e) { } private void chart1_Click(object sender, EventArgs e) { } private void Form1_Load_1(object sender, EventArgs e) { } } }
damiano_80