Matlab fsolve 传递参数

本文探讨如何在Matlab中利用fsolve函数和循环处理包含常数参数的非线性方程组。当有多个不同常数集(如C1到C10的5种组合)时,而不是手动多次重写方程,可以尝试在自定义函数@myfun内实现循环,以此求解10个未知数。示例中建议使用匿名函数来捕获问题的参数,通过将特定的c值赋给参数,创建一个一元匿名函数调用myfun,并将此匿名函数传递给fsolve。
摘要由CSDN通过智能技术生成

Suppose I have 10 equations and 10 unknowns. In the equations there are 10 constants that I don’t optimize, say C1,C2,…C10.

Is there a way to use Fsolve and Loops to solve my equations if I have 5 different sets of constants ( 5 times C1,C2,…C10) that satisfy my original 10 equations. Simply put, instead of rewriting my 10 equations and 10 unknowns… 5 times by hand, is there a way to loop inside the @myfun m-file I wrote to solve for my 10 unknowns?

Use anonymous functions, available in MATLAB since R14 I believe.

From fsolve help:

If FUN is parameterized, you can use anonymous functions to capture the problem-dependent parameters. Suppose you want to solve the system of nonlinear equations given in the function myfun, which is parameterized by its second argument c. Here myfun is an M-file function such as

         function 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值