To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
Hi to everybody,
I have implemented a little function that calculates the impulse response from a complex dataset (FR_data).
I am trying to test how different FR_data influnce the impulse response so I plot the FR_data over frequency using plot(frequency,abs(FR_data)) and after I ran the routine and plot the results again using plot(time,abs(y)).
the routine looks like:
L=length(FR_data); Y=zeros(1,2*length(FR_data)); Y(2:L+1)=FR_data; Y(L+2:end)=fliplr(FR_data(1:end-1)); y=ifft(Y); end
I notice that when I boost the higher frequencies in my FR_data the peak of the impulse response gets closer to time 0 and increases in amplitude and is somehow shorter. When I boost the low frequencies then the peak of the impulse response gets further away from time 0, decreases in amplitude and is wider.
Can anybody enlighten me please on if this is normal behaviour?
Furthermore, all the impulse responses exhibit a very very short and sharp maximum amplitude on time 0 (actually it extends for 2-3 samples, then dies out and then the impulse response follows. Is there a way to interpret this?
Any input would be greatly appreciated.
thank you for your patience
A small addition that might explain better what I am talking about. My datasets looks like: https://picasaweb.google.com/106674205971471180972/Matlab?authkey=Gv1sRgCKjU47ij4922SQ#5743069984065489538 they represent complex data that extend from 1 Hz to 20 kHz with a step of 1 Hz. So 20000 data. When I plot abs of those in a semilogx I get: https://picasaweb.google.com/106674205971471180972/Matlab?authkey=Gv1sRgCKjU47ij4922SQ#5743069982822662066. They represent 3 different FR_data sets. The x axis represents frequency.
After I run my routine I get IRs that look like: https://picasaweb.google.com/106674205971471180972/Matlab?authkey=Gv1sRgCKjU47ij4922SQ#5743069982995627554 and a zoomed version in the beginning of the x axis to actually see the IRs: https://picasaweb.google.com/106674205971471180972/Matlab?authkey=Gv1sRgCKjU47ij4922SQ#5743070000860043586 The x axis here represents the samples (not the time).
No products are associated with this question.
thanks for the contribution once again. I would like to upload some images on what i am talking about here, indeed, but I can't seem to find a way to attach them on my post.
The IR plots are plotted using plot(abs(y)). So no time on x axis just samples.
The function I am using to generate my FR_data is:
c=343; f=1:res:20000; B=1; R12=1; R1=h; R2=h; xl=wx/2; yl=wy/2; k=2*pi*f/c; psi=0; l=1./k;
% syms u v;
% Pinf=zeros(1,length(k)); % P=zeros(1,length(k));
% for i=1:1:length(k)
ul= cos(psi) * sqrt( (R1+R2)./(2*l*R1*R2) ).* wx; vl= sqrt( (R1+R2)./(2*l*R1*R2) ).* wy;
% A=(1j*B*R12*exp(-1j*k(i)*(R1+R2)))/(2*(R1+R2)); % I1=int(exp(-1j*(pi/2)*(u^2)),u,-ul,ul); % I2=int(exp(-1j*(pi/2)*(v^2)),v,-vl,vl);
[Cul Sul]=fcs(ul); [Cvl Svl]=fcs(vl);
I1=2*( Cul - 1j*Sul); I2=2*( Cvl - 1j*Svl);
G = ( 1j* I1.* I2 )/2;
where fcs is taken from http://www.mathworks.com/matlabcentral/fileexchange/6580 in order to calculate the fresnel integrals.
I use h=2, res=1 and I play with wx and wy.
What this function gives me is the frequency response I was talking about.
I reran through the process of generating the Frequency Response data (G) using your code and the one from the FEX just to see if there could have been any steps that were not properly handled in converting it to the time-domain... but I still got the same bizarre looking Impulse Response you provided pictures of. As I am not familiar with the type of FR function you are using, I cannot really comment on why the shape looks so bizarre... but I can tell you that the "spike" at your first time-domain data sample is basically equal to mean(real(G)). This is simply a consequence of having real frequency amplitudes that have a static shift, in this case they are all pretty much centered around 1... so you get a spike with amplitude 1 at your first time-domain data sample. If you were to subtract your frequency-domain data by 1, you would get rid of this spike in the time-domain.
Not sure if I have any other helpful advice if you are expecting a different shaped IR in the time domain without knowing where this FR formulation is coming from.
I forgot to mention, that I would change your :
because your first non-zero frequency will not always be 1 (only when res=1 is that valid).
I am only going to add the next bit just so you can double check the way you create your symmetric frequency response data (a little more general than my previous post):
N = numel(G); % number of non-zero, positive frequency amplitudes df = (f(end)-f(1))/(N-1); % frequency increment Nyq = f(end); % Nyquist frequency Fs = 2*Nyq; % Sample frequency %Fs = 2*N*df; %<--- should be same as above newN = 2*N; % Number of samples in the full frequency response spectrum %newN = Fs/df; %<--- should be same as above
newG = zeros(newN,1); % Pre-allocate full spectrum array newG(2:1+N) = G; % populate non-zero, positive frequency amplitudes newG(2+N:end) = fliplr(conj(G(1:end-1))); % neg. frequency amplitudes % newG = newG - mean(real(newG)); %<---- remove that spike in time-domain % newG = newG*Fs; %<---- correct time-domain amplitudes newf = -Nyq : df : Nyq-df;
% Plot Frequency Response % figure; plot(newf, abs(newG));
% Plot Impulse response t = (0:newN-1)/Fs; % time g = ifft(newG); figure; plot(t,g);