help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory exhausted


From: Mirek Kwasniak
Subject: Re: memory exhausted
Date: Thu, 19 Feb 1998 15:36:32 +0100

On Wed, Feb 18, 1998 at 06:19:09PM +0100, Fulko van Westrenen wrote:
> 
> Hello,
> 
> I made a quick-and-dirty function-file to do some filtering using fft.
> The datafile contains 2318x2 points (the measured variable and time)
> When I try to filter I get 
> error: memory exhausted -- trying to return to prompt
> 

You maked some mistakes. I tried to remove its. But I don't understand fully
your idea. Can you explain what function welch does?.

I send below diffs for your files.

Mirek Kwasniak


--- Arc/f.m     Thu Feb 19 11:56:07 1998
+++ f.m Thu Feb 19 15:18:42 1998
@@ -1,16 +1,20 @@
 function [retval] = f(data,freq);
 
 hrv=data(:,2);
 hrv=welch(hrv);
 a=rows(data);
 hrv=fft(hrv);
-b=1/(a*5);
-c=fix(freq/b)+1;
-v=zeros(a)';
+% b=1/(a*5);
+% ^^^^^^^^^ lowpass filter whith 0.2*freq ???
+% s=fft(x) gives double sided spectrum with part for negative
+% frequencies moved to right and flipped (and  s(1) = mean(x))
+% length of real spectrum = length(x)/2 
+c = fix( (a/2) * (1/5) ); 
+v=zeros(a,1); %use size(a)
 v(1:c)=1;
-v(a-c+1,a)=1;
+v(a-c+1:a)=1;
 hrv=hrv.*v;
-hrv=abs(ifft(hrv));
+hrv=real(ifft(hrv)); % Use real() to remove errors of ifft for real signals
 data(:,2)=hrv;
 retval=data;
 endfunction

--- Arc/welch.m Thu Feb 19 11:58:46 1998
+++ welch.m     Thu Feb 19 14:37:37 1998
@@ -1,9 +1,8 @@
 function [retval] = welch(A);
   A=A(:);
   a = size(A,1);
   H = [1:a]';
-  for j=1:a
-    H(j) = 1-(((j-1)-0.5*(a-1))/(0.5*(a+1)))**2;
-  endfor
+  H = 1-(((H-1)-0.5*(a-1))/(0.5*(a+1))).**2; % Never use loop when don't needed
   retval=A.*H;
 endfunction



reply via email to

[Prev in Thread] Current Thread [Next in Thread]