Created
September 21, 2017 01:57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace r05546043HongyiAss01 | |
{ | |
public partial class Form1 : Form | |
{ | |
private readonly object txbGSigma; | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
//不小心寫錯 | |
private void button1_MouseCaptureChanged(object sender, EventArgs e) | |
{ | |
} | |
//不小心寫錯 | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
//BTN 快押兩次 | |
double c, sigma; | |
//c = txbGextbox.Text | |
//.net framework 類別轉換 | |
c = Convert.ToDouble(textBox1.Text); // string convert to double involve | |
sigma = Convert.ToDouble(textBox2.Text); | |
chart1.Series[0].Points.Clear(); // 清除原始 Diagram before 進入 Loop | |
//<!------CHART--------------> | |
for (double x = -10; x <= 10; x = x + 0.1) | |
{ | |
double y; | |
y = Math.Exp(-(x - c) * (x - c) / sigma / sigma); | |
chart1.Series[0].Points.AddXY(x, y); | |
} | |
// for (double i = -10; i <= 10; i = i + 0.1) | |
// { | |
// //double j, k, l; | |
// //j = 0; | |
// //k = 0; | |
// //l = 0; | |
// switch (i,j,k) | |
// { | |
// case 1: | |
// Console.WriteLine(); | |
// break; | |
// case 2: | |
// Console.WriteLine(); | |
// break; | |
// default: | |
// break; | |
// } | |
// } | |
//} | |
//<!------------------c小題-------------------> | |
for (double z2 = -10; z2<= 10; z2 = z2 + 0.1) //修改變數名稱 | |
{ | |
double a3,c3,b3, Ans; | |
a3 = b3 = c3 = 0; | |
Ans =1 / (1 + Math.Pow( (Math.Abs((z2 - c3) / a3)), 2*b3 )); | |
} | |
} | |
// mistake | |
private void label3_Click(object sender, EventArgs e) | |
{ | |
} | |
private void label5_Click(object sender, EventArgs e) | |
{ | |
} | |
private void label1_Click(object sender, EventArgs e) | |
{ | |
} | |
private void button3_Click(object sender, EventArgs e) | |
{ | |
} | |
//mistake | |
private void textBox3_TextChanged(object sender, EventArgs e) | |
{ | |
//<!-----------第a小題--------------------> | |
//Array[i,j,k] | |
double a, b, c1; | |
// a = b = c1 = 0; | |
a = Convert.ToDouble(textBox3.Text); | |
b = Convert.ToDouble(textBox4.Text); | |
c1 = Convert.ToDouble(textBox5.Text); | |
chart1.Series[0].Points.Clear(); // 清除原始 Diagram before 進入 Loop | |
for (double z = -10; z <= 10; z = z + 0.1) // z = x for Q1 | |
{ | |
if (z <= a) | |
{ | |
z = 0; | |
} | |
else if (a <= z && z <= b) | |
{ | |
z = (z - a) / (b - a); | |
} | |
else if (b <= z && z <= c1) | |
{ | |
z = (c1 - z) / (c1 - b); | |
} | |
else if (z >= c1) | |
{ | |
z = 0; | |
} | |
else | |
{ } | |
chart1.Series[0].Points.AddXY(z, a, b, c1); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment