matlab 指定函数拟合,matlab多项式拟合以及指定函数拟合

clc;

clear all;

close all;

%% 多项式拟合指令;

% X = [1 2 3 4 5 6 7 8 9 ];

% Y = [9 7 6 3 -1 2 5 7 20];

% P= polyfit (X,Y,3);

%

% x = 0:2:10;

% y = polyval(P,x);

% plot(x,y,X,Y,‘r*‘);

%% 指定函数拟合

x=[ 0;0.4;1.2; 2;2.8;3.6;4.4;5.2; 6;7.2; 8;9.2;10.4;11.6;12.4;13.6;14.4;15];

y=[ 1;0.85;0.29;-0.27;-0.53;-0.4;-0.12;0.17;0.28;0.15;-0.03;-0.15;-0.071;0.059; 0.08;0.032;-0.015;-0.02];

plot(x,y,‘r*‘)

hold on

f = fittype(‘a*cos(k*t)*exp(w*t)‘,‘independent‘,‘t‘,‘coefficients‘,{‘a‘,‘k‘,‘w‘});

cfun = fit(x,y,f);

xi = 0:1:20;

yi = cfun(xi);

plot(xi,yi,‘b-‘)

%程序中,函数fittype是自定义拟合函数;cfun=fit( x, y, f)是根据自定义的拟合函数f 来拟合数据 x

原文:http://www.cnblogs.com/Kermit-Li/p/4325614.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值