syntax to pass x0 values (for fsolve) from constant blocks to interpreted matlab function

1 view (last 30 days)
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

Answers (1)

Kaustubha Govind
Kaustubha Govind on 2 Aug 2012
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.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!