MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   寻求解决方案!= 0 (https://www.labfans.com/bbs/showthread.php?t=23898)

poster 2019-12-10 20:48

寻求解决方案!= 0
 
我想在for循环的每个循环中为不同的值求解方程式。我通常在m-file函数中包含要求解的值,但无法在for循环的每个循环中更改m文件。有没有一种方法可以解决fsolve的问题,但是要使用值!= 0。



[B]回答:[/B]

您可以使用[URL="http://www.mathworks.com/help/techdoc/matlab_prog/f4-70115.html"]匿名函数[/URL] 。因此,如果您的参数化函数为:

function y = f(x, c) ... end 那么您可以遍历不同的参数,从而:

for c = 0:10 fsolve(@(x)f(x,c), x0); end (未经测试)



[url=https://stackoverflow.com/questions/3694587]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 08:35

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.