Sum of a signal in simulink

21 vues (au cours des 30 derniers jours)
Sam136
Sam136 le 4 Août 2015
Modifié(e) : Yeow Yu Leong le 9 Juin 2024
In my Simulink model, current value of a signal should be added to all previous value of the same signal. I've used integrator with initial value of zero to find it; however the result is different from what I find in Matlab through "sum" or "trapz" function. The solver is continuous with fixed step size. Any thought to resolve this issue. or any other block to use for this purpose instead of integrator?

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 4 Août 2015
Modifié(e) : Azzi Abdelmalek le 4 Août 2015
You can use a Matlab function block with this code
function y=fcn(u)
persistent a
if isempty(a)
a=0
end
y=u+a;
a=y;
You can also use a discrete transfer function 1/(z-1)
  1 commentaire
Yeow Yu Leong
Yeow Yu Leong le 9 Juin 2024
Modifié(e) : Yeow Yu Leong le 9 Juin 2024
or use an accumulator

Connectez-vous pour commenter.

Plus de réponses (1)

Sean de Wolski
Sean de Wolski le 4 Août 2015
You could also use a unit delay:
  1 commentaire
Azzi Abdelmalek
Azzi Abdelmalek le 4 Août 2015
He is asking for all previous values. This will calculate out(n)+out(n-1)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by