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

답변 (1개)

Kaustubha Govind
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.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by