Insert variable workspace in embedded MATLAB function
Show older comments
Hello, I find the following problem when I try to load a .mat file (containing parameters) into a simulink block (embedded MATLAB function). That is:
function y = fcn(u)
%#eml
load('var_mod');
if u <= L
y = go;
elseif u > L && u < L+s+(dp/2)
y = sqrt((u - L)^2 + go^2);
elseif u >= L+s+(dp/2) && u < L+d
y = (sqrt((-u + L + d)^2 + go^2));
else
y = go;
end;
Where L, d, go and so on should be read from the file var_mod.
The compilation gives the following error:
Function 'load' implicitly resolved in the MATLAB workspace. Implicit evaluation in MATLAB is not supported. Please declare this function extrinsic using eml.extrinsic('load'), or call it using feval.
Function 'Embedded MATLAB Function' (#18.27.42), line 4, column 1:
"load('var_mod')"
Launch diagnostic report.
How can I solve this?
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!