52matlab技术网站,matlab教程,matlab安装教程,matlab下载

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 696|回复: 0

001-Matlab-牛顿法解非线性方程组-2018/12/17

[复制链接]

87

主题

151

帖子

1588

积分

版主

Rank: 7Rank: 7Rank: 7

积分
1588
发表于 2018-12-17 08:26:34 | 显示全部楼层 |阅读模式
本帖最后由 matlab的旋律 于 2018-12-17 10:07 编辑

项目需求如下:


使用牛顿法解方程组.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%主函数代码 main.m
clear
close all
clc

t0=[470 200];   % 迭代初始值
eps = 1e-6;  % 定位精度要求

for i = 1:10
    f = double(subs(Function(t0),{'t2' 't3'},{t0(1) t0(2)}));
    df = double(subs(deFunction(t0),{'t2' 't3'},{t0(1) t0(2)}));  % 得到雅克比矩阵
    t = t0 - f/df;
    if(abs(t-t0) < eps)
        break;
    end
    t0 = t; % 更新迭代结果
end
f = double(subs(Function(t0),{'t2' 't3'},{t0(1) t0(2)}));

disp(['定位坐标',num2str(t)]);
disp(['迭代次数:',num2str(i)]);
disp(['方程组的值:',num2str(f)])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%定义非线性方程组如下
function f = Function(t)

%变量t1 t2
%函数f1 f2
syms t2 t3
f1 = -191*t2^2/4000000 - 203471*t2/2000000 + 23*t3^2/2000000 + 10971*t3/2000000 + 1808829/32000;
f2 = 7*t2^2/1000000 + 3339*t2/1000000 - 7*t3^2/100000 - 18339*t3/1000000 + 9/10;
f=[f1 f2];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%雅克比矩阵
function df = deFunction(t)

f = Function(t);
df = [diff(f,'t2');diff(f,'t3')]; %雅克比矩阵


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|52matlab技术网站 ( 粤ICP备14005920号-5 )

GMT+8, 2019-8-26 07:37 , Processed in 0.063646 second(s), 21 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表