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?
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)