matlab拟合

来源:百度文库 编辑:神马文学网 时间:2024/04/26 06:14:33
1. Copy the data into some file named test1.txt

Fig. 1
2. Open Matlab, load the test1.txt into Matlab workspace

Fig. 2

Fig. 3

Fig. 4

Fig. 5
3. Generate T and x vector:
Enter T= test1(:, 1), x= test1(:, 3) in the command window

Fig. 6
4. Enter cftool in the command window:
cftool

Fig. 7
Choose Data…and choose X Data: x, Y Data: T

Fig. 8

Fig. 9
Then Click “Create data set”

Fig. 10
Close it
Choose “Fitting…” (see the second red box in Fig. 8)

Fig. 11
Click “New Fit”
Choose “Type of fit”= “Custom Equations”

Fig. 12
Click “New”

Fig. 13
Choose “General Equations”

Fig. 14
Enter the equation you want to fit:
Box 1: T
Box 2: log(x) %% in Matlab log(x) is the ln(x) in traditional math (log(x)=ln(x), log10(x)=lg(x))
Box 4: The data here is auto create by Matlab (default), you can ignore it for the present
BTW, you can change the equation from log(x)= A+B/T+C*log(T) to x= exp(A+B/T+C*log(T)) or something like this, but perhaps it will not affect the fitting results.

Fig. 15
Click “OK”
Back to the Fitting window, Click “Apply”

Fig. 16
OK, the result shows as follows.
If the result is not as you expected, you can choose “Fitting options” to adjust some parameters such as SartPoint (like Box 4 Fig. 15). Try by yourself please, any question please ask Google.

Fig. 17
To make the fitting figure looks better, you can drag the legend in the right-upper corner by click the left mouse without release.

Fig. 18
OK, that’s all. Almost forget that the Matlab I used in the tutorial is:

Fig. 19
I have no idea that whether all Matlab has cftool. You can try to test is by enter cftool in the command window by yourself. Hope it works on your machine.