add up a signal for every timestep
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello i've got an embedded matlab function in my model, which creates an output signal(wastage of fuel). Now i want to add up this signal for every timestep, so that i obtaine the total wastage after the simulation. Is there a way? Hope that was understandable ;)
2 commentaires
Réponse acceptée
Azzi Abdelmalek
le 16 Mar 2013
Modifié(e) : Azzi Abdelmalek
le 16 Mar 2013
Ok, you want a cumulative sum:
In your embedded function add these codes
at the beginning
function [☺utput,cum_output]=fcn(....)
persistent cum_output
if isempty(cum_output)
cum_output=0
end
and at the end of your code
cum_output=cum_output+output
11 commentaires
Azzi Abdelmalek
le 17 Mar 2013
st, I can't answer this question, because you did not provide enough information. What is sure is the code I added allows you to do cumulative sum.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur String dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!