matlab function syms slows down simulink model
7 次查看(过去 30 天)
显示 更早的评论
Hi,
i want to calculate the syms function y in a matlab function block in simulink . There is a slow and a fast option:
slow option:
matlab function in simulink:
------------------------
function y = fcn(v)
coder.extrinsic('calc_y') % is needed, otherwise simulink prints an error
y =0;
y = calc_y(v);
------------------------
which calls the extrinsic matlab function:
------------------------
function y = calc_y(v)
y = evalin('base','y'); % Read syms function y from workspace
y = double(subs(y,v));
------------------------
y is a syms function in the workspace : y =2v +v +5; % dummy function
The code works, but it is very slow.
fast option:
The fast solution is to copy y in the matlab function block like:
matlab function in simulink:
------------------------
function y = fcn(v)
y =2v +v +5; % no syms function anymore
------------------------
y is calculated in matlab init file and can be changed in the initialization. So with the fast option i need to copy the y function everytime by hand.
The problem of the caluclation speed is the syms function.
Is there any workaround to not declare it as syms function and copy the function automatically in the matlab function block in simulink?
Thanks and Regards!
Bernd
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!