I have a large vector of input and output data (both voltages) and I need to obtain a bode-like representation of the transfer function numerically. To use the full scope at once I choose a quasi random signal of a certain bandwidth.
Using the Fourier transformation I can plot this bode diagram for not too small frequencies, but this is exactly the problem. Due to experimental reasons I can measure the response at most for 5 minutes, whereas the time constant I am looking for should be something like 1300 seconds ( around 20 minutes) and the change of gain is also pretty small.
But even with this methodology (momentary working progress is shown below) the very small frequencies are unreachable. Is there / do you know of any solutions in either vanilla MATLAB or signal processing TB? I tried using pmtm today but this didn't give any meaningful results either.
Thanks for any help in advance,
Markus
function [r,phi,lgw] = bodenum2(a,b,f,maxom)
% a,b = signals; f = sampling rate;
% maxom = truncation of frequency scale
if nargin <4
maxom = 2;
end
%a=a(:)';
%b=b(:)';
w = 2.^linspace(0,-1,61);
w = w(1:end-1);
l = length(a);
lgw = zeros(1,0);
c = complex(lgw);
for k=round(w*l)
indm = floor(min(10^(maxom-log10(2*pi*f/k)),k/2-.5));
z=fft(a,k);
afft=z(2:indm+1);
z=fft(b,k);
c = [c,afft./z(2:indm+1);]; %#ok
lgw = [lgw,log10(1:indm)+log10(2*pi*f/k)]; %#ok
end
[lgw,ind]=unique(lgw);
% smoothing average
if 1
n = 10;
f4 = exp(-(-n:n).^2*8/n^2);f4=f4/sum(f4);
c = conv(f4,c([ind(1:n) ind]));
c = c(2*n+1:end-n);
else
c=c(ind);
end
r = abs(c);
phi = angle(c);
figure;
subplot(2,1,1);
plot(lgw,log10(r),'Marker','.');
subplot(2,1,2);
plot(lgw,phi/pi*180,'Marker','.');
end
Rereading your post makes me think you're looking for this one:
figure;
subplot(2,1,1);
plot(log10(2*pi*frequency),log10(gain));
ylabel('Gain [dB]');
subplot(2,1,2);
plot(log10(2*pi*frequency),phase/pi*180);
ylabel('Phase [deg]');
xlabel('Log_{10}(\omega)'}
Hope this helps,
Markus
I am getting an error. Matlab says 'Error in bodenum2' at 24
c = [c,afft./z(2:indm+1);];
CAT arguments dimensions not consistent.
Please help ..
zeeshan
"Markus trtr" <trtr...@spam.la> wrote in message <gsnn6d$25m$1...@fred.mathworks.com>...
To convert frd object into a transfer function, you will need to use System Identification Toolbox.
see
>>doc frd
and these demos to get started:
http://www.mathworks.com/products/control/demos.html?file=/products/demos/shipping/control/FRDPlantdemo.html
http://www.mathworks.com/products/sysid/demos.html?file=/products/demos/shipping/ident/iddemofr.html
HTH.
Arkadiy
"siti " <salbi...@yahoo.com> wrote in message <gqimv9$2cm$1...@fred.mathworks.com>...
Thanks for your reply.
My case is a bit complex. I have a frequency sweep at the input and a relative response at the output. I repeat each frequency for 6 periods to have a good resolution. Now i need to find the bode of this reponse. If loaded directly as an
frd object the response is not at all correct as shown by the frequency response function. I have plotted the mag response but phase seems to be difficult. There are some nonlinearities in the system which make it difficult to measure the phase difference at a suitable point. Any idea ??
zeeshan
"Arkadiy Turevskiy" <arkadiy....@mathworks.com> wrote in message <hmjkn1$rt6$1...@fred.mathworks.com>...