syntax to pass x0 values (for fsolve) from constant blocks to interpreted matlab function
1 次查看(过去 30 天)
显示 更早的评论
i use a interpeted matlab function to do fsolve inside simulink and i used constant blocks with a mux to supply the needed parameters.
is there a possibility to do the same with x0? if yes, what would the syntax be? i tried x0=[u(5),u(6),u(7)] or just [u(5),u(6),u(7)], but none of them seems to work.
fsolve(@(x)myfun(x,u(1),u(2),u(3),u(4)),x0,optimset('MaxFunEvals', 100, 'FunValCheck', 'on','MaxIter', 800000,'TolX', 1e-60,'TolFun', 1e-60))
best regards
0 个评论
回答(1 个)
Kaustubha Govind
2012-8-2
You should probably create a wrapper function that has the two lines:
function y = callFsolve(u)
x0=[u(5),u(6),u(7)];
y = fsolve(@(x)myfun(x,u(1),u(2),u(3),u(4)),x0,optimset('MaxFunEvals', 100, 'FunValCheck', 'on','MaxIter', 800000,'TolX', 1e-60,'TolFun', 1e-60));
And then call callFsolve(u) from the block dialog. If it still doesn't work, you could set a breakpoint in your code to see what it going wrong.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!