How to write a matlab code to perform moving compuation for any equation?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Kalasagarreddi Kottakota
il 8 Gen 2023
Modificato: Sulaymon Eshkabilov
il 8 Gen 2023
Lets say I have a vector of 1000 random numbers and want to sum every 30 numbers of the vector and store it in a variable.
0 Commenti
Risposta accettata
Sulaymon Eshkabilov
il 8 Gen 2023
Modificato: Sulaymon Eshkabilov
il 8 Gen 2023
There are a couple of ways to do it, e.g.:
V = randi([-10, 100], 1, 1000);
n = 1:30:numel(V);
for ii=1:numel(n)-1
Vs(ii)=sum(V(n(ii):n(ii+1)));
end
numel(Vs)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!