FSOLVE inside for loop to change a parameter and save it
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
hi guys! i have this problem. i use fsolve to solve 3x3 non linear system and i want to change a parameter "ua" every iteration, and then i want to save the vector x and plot ua(n) vs x(n), any idea.
im using this code for example:
c lc
clear all
x0 = [-5; -5]; % Make a starting guess at the solution
options=optimset('Display','iter'); % Option to display output
k=100;
for n=2:100;
ua(1)=1;
ua(n)=ua(n-1)+0.1;
[x,fval] = fsolve(@(x) myfun(x,ua(n-1)),x0,options) % Call solver
end
the func file reads like this
function F = myfun(x,ua)
F = [ua*2*x(1) - x(2) - exp(-x(1));
-x(1) + 2*x(2) - exp(-x(2))];
回答(0 个)
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!