Definite sum in MATLAB

Status
Not open for further replies.

Mona7150

Member level 1
Joined
Nov 9, 2013
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
249
Hello all,

I have a parameter in frequency domain say x(f) calculated for 0 to 100GHz but I want to sum up the x's from 50 to 60 GHz only. How should I write this in MATLAB?
 

Hallo,

if f is the frequency array and X(f) your signal

startFreqIdx = find(X >= F_0, 1 ); % the first index of X(f) with frequency f>= F_0
stopFreqIdx = find(X <= F_1, 1, 'last' ); % the last index of X(f) with frequency f<= F_1

S = sum(X(startFreqIdx : stopFreqIdx ))

This should work (precondition: f axes has been assumed in increasing order)

Mowgli
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…