matlab简介与简单示例.ppt

  1. 1、本文档共69页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
matlab简介与简单示例matlab简介与简单示例

二分法: 用二分法求解函数g(x)=x^2-x-2在[0,3]上的近似根 7.非线性方程组的数值解(数值分析) function [c,err,yc]=bisect(f,a,b,delta) %Input - f is the function % - a and b are the left and right endpoints % - delta is the tolerance %Output - c is the zero % - yc= f(c) % - err is the error estimate for c ya=f(a); yb=f(b); if ya*yb 0,return,end max1=1+round((log(b-a)-log(delta))/log(2)); 7.非线性方程组的数值解(数值分析) for k=1:max1 c=(a+b)/2; yc=f(c); if yc==0 a=c; b=c; elseif yb*yc0 b=c; yb=yc; else a=c; ya=yc; end if b-a delta, break,end end c=(a+b)/2; err=abs(b-a); yc=f(c); 7.非线性方程组的数值解(数值分析) f=inline(‘x.^2-x-2’); [c,err,yc]=bisect(f,0,3,0.00001) 7.非线性方程组的数值解(数值分析) 牛顿迭代法: X^2-5=0的根 初始点选为2,求解正跟 7.非线性方程组的数值解(数值分析) function [p0,err,k,y]=newton(f,df,p0,delta,epsilon,max1) %Input - f is the object function % - df is the derivative of f % - p0 is the initial approximation to a zero of f % - delta is the tolerance for p0 % - epsilon is the tolerance for the function values y % - max1 is the maximum number of iterations %Output - p0 is the Newton-Raphson approximation to the zero % - err is the error estimate for p0 % - k is the number of iterations % - y is the function value f(p0) 7.非线性方程组的数值解(数值分析) for k=1:max1 p1=p0-f(p0)/df(p0); err=abs(p1-p0); relerr=2*err/(abs(p1)+delta); p0=p1; y=f(p0); if (errdelta)|(relerrdelta)|(abs(y)epsilon),break,end end 7.非线性方程组的数值解(数值分析) f=inline(x.^2-5); df=inline(2*x); [p0,err,k,y]=newton(f,df,2,0.01,1e-6,1000) 7.非线性方程组的数值解(数值分析) 4.曲线拟合和回归分析 拟合工具箱 4.曲线拟合和回归分析 回归分析 matlab一元线性回归和多元线性回归 regress命令 [b,bint,r,rint,stats]=regress(y,x); b为系数;bint为参数b的95%的置信区间;r为残差;rint为残差r的95%的置信区间;stats包含可决系数r^2,F值以及回归的p值。 4.曲线拟合和回归分析 clear all; % 数据的输入 x1=0.1:0.01:0.18; x2=[x1 0.2 0.21 0.23]; y=[42.0 41.5 45.0 45.5 45.0 47.2 49.0 55.0 50.3 55.0 55.5 60.5]; x=[ones(12,1),x2]; % 作数据的散点图 plot(x2,y,rp); % 回归分析 [b,bint,r,rint,stats]

文档评论(0)

kxiachiq + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档