フィルターのクリア

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

1 回表示 (過去 30 日間)
Hana
Hana 2012 年 8 月 2 日
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 Center および File ExchangeSimulink Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by