How to use circshift in Simulink?
Mostrar comentarios más antiguos
I have a vector signal in Simulink that I want to transform so that each value is replaced by the average of that value and the subsequent value. My first idea was using a MATLAB function block with the following code:
function y = fcn(u)
y = (u+circshift(u,1))/2;
However, this somehow changes the vector to a matrix and leads to an error message:

I don't fully understand this behavior, but it is probably caused by reasons described in the answers to a previous question:
Are there other ways to perform this function using standard Simulink blocks?
3 comentarios
Mathieu NOE
el 3 de Abr. de 2025
In other words you want to do a average using the current and past value so either you use a FIR filter , or simply use a delay / memory block to store the previous sample (so you are re-creating a 2 taps FIR filter)
Walter Roberson
el 3 de Abr. de 2025
The first thing I would wonder is whether u is a row vector or column vector; the distinction would make a difference to the circshift() call.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Get Started with DSP System Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
