0.Matlab自带函数拟合
用三角函数拟合数据简单方便,matlab自带的fittype函数即可完成拟合任务,但是fittype函数仅限于matlab,为了搞懂fittype函数的内含,自己写了一套函数用于拟合。
如下图所示,现有一不规则散点,命令用三角函数拟合,拟合的目标频率w0为0.01m^-1
拟合目标方程为y=a * sin(2 *pi *w0 * x+b)
拟合效果如下所示
matlab代码
clc
clear
close all
%%
x=[83.0755634114008,83.2523199292974,83.4290764471940,83.6058329650906,83.7825894829872,83.9593460008838,84.1361025187804,84.3128590366770,84.4896155545736,84.6663720724702,84.8431285903668,85.0198851082634,85.1966416261600,85.3733981440566,85.5501546619532,85.7269111798498,85.9036676977463,86.0804242156430,86.2571807335395,86.4339372514361,86.6106937693328,86.7874502872294,86.9642068051259,87.1409633230225,87.3177198409191,87.4944763588157,87.6712328767123,87.8479893946089,88.0247459125055,88.2015024304021,88.3782589482987,88.5550154661953,88.7317719840919,88.9085285019885,89.0852850198851,89.2620415377817,89.4387980556783,89.6155545735749,89.7923110914715,89.9690676093681,90.1458241272647,90.3225806451613,90.4993371630579,90.6760936809545,90.8528501988511,91.0296067167477,91.2063632346443,91.3831197525409,91.5598762704375,91.7366327883341,91.9133893062307,92.0901458241273,92.2669023420239,92.4436588599205,92.6204153778171,92.7971718957137,92.9739284136103,93.1506849315069];
y=[6.87890923862375,7.44460436546077,8.13175107815217,7.49866403889575,7.62502419742431,7.27754868283910<