fsolve变参数问题。
14 ビュー (過去 30 日間)
古いコメントを表示
腾龙公司开户《 TL10150.com 》
2022 年 10 月 16 日
回答済み: 果博东方注册开户【558766.com】
2022 年 10 月 16 日
小白求问对一个变参数的非线性方程用fsolve求解怎么写的,例如对函数f=a-b*exp(c*x),需要重复求解这一方程,其中a,b,c给定一个初值后每次计算都是与解的累加相关;
a=1;b=2;c=3;
n=1:30
解f=a-b*exp(c*x);
a=a+x;
b=2*(b+x);
c=3*(c+x);
end
大概这样,有没有不用句柄的方法啊,句柄老是出错;用num2str改成字符串也有问题
a=1;
>> b=2;
>> fsolve('1-',num2str(a),'*exp(',num2str(b),'*x)',0)
Error using fsolve (line 145)
FSOLVE requires the following inputs to be of data type double: 'X0'.
求大佬帮解决
0 件のコメント
採用された回答
果博东方注册开户【558766.com】
2022 年 10 月 16 日
主函数:
clc
clear
close all
tic
a=1; b=2; c=3;
for i = 1 : 30
x0 = fsolve(@(x) myfun(x,a,b,c),0);
a = 1 + x0; b=2*(b+x0); c=3*(c+x0);
X(i) = x0;
end
plot(X)
toc
子函数:
function F = myfun(x,a,b,c)
F = a - b*exp(c*x);
运行结果:
[attach]257864[/attach]
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!