SIMULINK: Managing (saving) variable state in embedded matlab function -


each time matlab function called stateless, have values of input variables. how manage state (i.e., values of variables) between cycles? example, on step 100 made calculation, need use on step 200. have used global variables, not supported.

this persistent variables for. see >>doc persistent more information, want following

function y = fcn(u)  %define persistent variables persistent b c  % initialize persistent variables (at t=0) if isempty(a)    = 1;    b = 10;    c = 12; end   % update variables = a+7; b = b+4;  % update out y = u + + b + c; 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -