loop and array for sum
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
magnitude= abs(y); % amplitude of y signal
near= ceil(N/F);
signal= zeros(1,near);
for i=1:1000:N
for j=i:1:near
s = sum(magnitude(i:i+1000));
signal(j)= s;
end
end
I am trying to store every sum in array but instead, i get same result for every signal(j). I think i am missing something.
0 Kommentare
Antworten (2)
Steven Lord
am 12 Mai 2020
The expression you use to calculate s doesn't depend on j and also doesn't depend on anything that changes inside the loop over j. So it's expected that you receive the same answer each time.
I don't know how you want to modify your code so that the expression you use to calculate s has some dependence on j. If you post the mathematical expression you're trying to compute or the problem you're trying to solve as a comment we may be able to offer some guidance.
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!