Path: news.mathworks.com!not-for-mail
From: "Travis Bland" <travisbland88@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Ifft on modified array fails
Date: Sat, 7 Nov 2009 04:01:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 75
Message-ID: <hd2rdu$l9g$1@fred.mathworks.com>
References: <hd1tr4$9lk$1@fred.mathworks.com> <hd23bt$l4f$1@fred.mathworks.com>
Reply-To: "Travis Bland" <travisbland88@yahoo.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257566462 21808 172.30.248.38 (7 Nov 2009 04:01:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 7 Nov 2009 04:01:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2073693
Xref: news.mathworks.com comp.soft-sys.matlab:583179


"Matt " <xys@whatever.com> wrote in message <hd23bt$l4f$1@fred.mathworks.com>...
> "Travis Bland" <travisbland88@yahoo.com> wrote in message <hd1tr4$9lk$1@fred.mathworks.com>...
> > My end goal is to take an array, fft, set a range of frequencies equal to 0, and then ifft.
> > I get stuck once i set anything equal to 0. My ifft output is still complex. I stopped using my code, and just got an array in the workspace, manually changed a few entries to 0, and then tried plot(ifft(vf)) - i got scribbles, and complex results.
> =======
> 
> We need to see more.
> 
> Why do you expect to get real output from the ifft? Is it a symmetric spectrum? Are the frequencies being set to 0 in such a way as to preserve this symmetry? 

Yes and yes. It is a symmetric spectrum and i believe i modified it to preserve that. It's data taken from ice samples in antarctica. And i guess i just assumed a complex answer was wrong, if i can just do abs(vt) and get good results, that's fine with me.


Here's some of my code, i just copied the parts for 0-100 mhz (and left 100-1000 out)



load std000.txt
vt=std000(:,2)

%power of vt over entire length of data file
for n = 1:length(vt) ;
vt_s = vt_s + (vt(n) .^2);
end

vf = (fft(vt));
vf_s =0;

%power of vf over entire file
for k= 1:length(vt);
    vf_s = vf_s + (abs( (vf(k)/sqrt(N)) .^2));
end


% 0 - 100 mhz removed
freq100 = vf;
bandwidth = 2000000000;
N = length(vt);
bin_ratio = bandwidth / N;
low_cut = 1  ;    % user defined--- low cutoff 
high_cut = 100  ;  % user defined--- high cutoff 
low_bin = (low_cut * 1000000) / ( bin_ratio);
high_bin = (high_cut * 1e6) / (  bin_ratio);
 

high_bin = ceil(high_bin);
low_bin = floor(low_bin);



for i = 1:high_bin;
    freq100(i) = 0;
end


for p = (N - high_bin):(N - low_bin);
    freq100(p) = 0;
end 


%skipping through same calculations for different frequency ranges... we get to the %summation section

vt_100 = ifft(freq100);
vt_100_s = 0;
for n = 1:length(vt) ;
 vt_100_s = vt_100_s + (vt_100(n) .^2);
end







Thanks!