电子产业一站式赋能平台

PCB联盟网

搜索
查看: 1198|回复: 0
收起左侧

MATLAB@解含有积分的方程

[复制链接]

585

主题

910

帖子

4977

积分

四级会员

Rank: 4

积分
4977
发表于 2023-4-4 19:43:38 | 显示全部楼层 |阅读模式
用最小二乘法求积分的时候 设置函数格式的时候要将数据变成double形式 但是因为有积分就没法实现 应该怎么改正呢


clear;clc;syms t w p;%定义参数%生成数据w=[0.01,0.03,0.05,0.1,0.5,0.8,1,10,50,100]';func1=@(a)double(int((25*exp(-0.5/t^2+1/t-0.5)+10*exp(-0.5/t^2+1/t-0.5))*(1-1/(1+a^2*t^2))*(1/t),t,0.01,100));G1=arrayfun(func1,w);func2=@(a)double(int((25*exp(-0.5/t^2+1/t-0.5)+10*exp(-0.5/t^2+1/t-0.5))*(a*t/(1+a^2*t^2))*(1/t),t,0.01,100));G2=arrayfun(func2,w);G=G1+G2;%添加噪声G1_noise=[1,7,10,40,100,300,500,800,888,900]';G2_noise=[30,80,100,200,250,300,250,80,30,20]';G_noise=G1_noise+G2_noise;%调用Lspcurvefit函数func=@(p,w)double(arrayfun(@(a)int((p(1)*exp(p(2)/t^2+p(3)/t+p(4))+p(5)*exp(p(6)/t^2+p(7)/t+p(8)))*(1-1/(1+a^2*t^2))*(1/t),t,0.01,100) ...    +int((p(1)*exp(p(2)/t^2+p(3)/t+p(4))+p(5)*exp(p(6)/t^2+p(7)/t+p(8)))*(a*t/(1+a^2*t^2))*(1/t),t,0.01,100),w));%选择合适的初始值p0=[450,-1,0,0,180,-10,0,-0]';p=lsqcurvefit(func,p0,w,G_noise);%拟合结果y_fit_lsq=func(p,w);%调用nlinfitpp=nlinfit(w,G_noise,func,p0);y_dit_nlin=func(pp,w);
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


联系客服 关注微信 下载APP 返回顶部 返回列表