Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bode plot from frequency response

101 views
Skip to first unread message

siti

unread,
Mar 27, 2009, 10:14:01 AM3/27/09
to
i have frequency, gain and phase data get from experiment..
can matlab plot a bode plot from this data and get a transfer function from it?
if can how?
thank you...

Markus trtr

unread,
Apr 22, 2009, 2:21:01 PM4/22/09
to
Although I didn't quite get which data your experiment provides, I think I have a quite similar problem, on which I am working for over a week until now.

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

Markus trtr

unread,
Apr 22, 2009, 2:27:01 PM4/22/09
to
"siti " <salbi...@yahoo.com> wrote in message <gqimv9$2cm$1...@fred.mathworks.com>...

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

Zeashan

unread,
Mar 2, 2010, 12:08:04 PM3/2/10
to
Hi 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>...

Arkadiy Turevskiy

unread,
Mar 2, 2010, 1:17:05 PM3/2/10
to
Use the magnitude and phase to create the complex response Ae(j*phase).
The use function frd to create frd object.
Once you create it, you can use bode() to get the bode plot.

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>...

Zeashan

unread,
Mar 6, 2010, 1:28:06 PM3/6/10
to
Hi,

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>...

0 new messages