Reputation: 13
I am trying to calculate the interimvalues of a vector in SIMULINK. In MATLAB the code would look like this:
(u(2:end) + u(1:end-1))./2
The SIMULINK Function Block is unable to perform this operation because of the colon Operator ":" and the documentation only refers to the Math Function Block but it is not possible to enter a custom function there...
Do you know a simple way to calculate the interimvalues as described above?
Thank you very much for your help!
Upvotes: 0
Views: 302
Reputation: 932
Looking at the help file for the Fcn block it does state:
Also, this block does not support the colon operator (:).
so I guess that isn't going to work. You can build the expression in Simulink using Selector blocks, but probably the simplest solution is to use an Embedded MATLAB block with:
function y = fcn(u)
%#eml
y = (u(2:end) + u(1:end-1))./2;
Upvotes: 0