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

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 58946|回复: 1
打印 上一主题 下一主题

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

[复制链接]

125

主题

209

帖子

3072

积分

版主

Rank: 7Rank: 7Rank: 7

积分
3072
跳转到指定楼层
楼主
发表于 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
回复

使用道具 举报

0

主题

2

帖子

4

积分

新手上路

Rank: 1

积分
4
沙发
发表于 2022-4-11 17:50:04 | 只看该作者
可以学习一下
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 11:16 , Processed in 0.059963 second(s), 19 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

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