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

Convert frequency response data to simulink block

158 views
Skip to first unread message

Ben Wu

unread,
Sep 3, 2008, 10:37:02 PM9/3/08
to
I am doing research in my college.

Now, I am trying to build a noise cancelling system for
headphone in simulink. There is a block which should use a
microphone's transfer function. I test the microphone's
transfer function and get the frequency response data from
150hz to 5k hz with 130 points. And now, I don't know how to
convert the data to simulink's block, so it can work as a
microphone's behavior. I tried system identification
toolbox. But it doesn't work by now. I am just confused how
to do it.

Rune Allnor

unread,
Sep 4, 2008, 6:08:26 AM9/4/08
to
On 4 Sep, 04:37, "Ben Wu" <wushizh...@gmail.com> wrote:
> I am doing research in my college.
>
> Now, I am trying to build a noise cancelling system for
> headphone in simulink. There is a block which should use a
> microphone's transfer function.

You might get help if you state specifically what block
you try to use.

Rune

Ben Wu

unread,
Sep 4, 2008, 10:10:20 AM9/4/08
to
Rune Allnor <all...@tele.ntnu.no> wrote in message
<aa9087fa-066e-458f...@z6g2000pre.googlegroups.com>...

There is a block in my system that represent the microphone.
I want it to behavior like the microphone I use. Thus, I
test the microphone'r frequency response by a function
generator and a scope. Now, I want to convert the data I got
to the block.

David

unread,
Sep 4, 2008, 10:43:02 AM9/4/08
to
"Ben Wu" <wushi...@gmail.com> wrote in message
<g9oq8c$occ$1...@fred.mathworks.com>...

> Rune Allnor <all...@tele.ntnu.no> wrote in message
> <aa9087fa-066e-458f-b5b8-
041c2e...@z6g2000pre.googlegroups.com>...

maybe firls could be of help

Ben Wu

unread,
Sep 4, 2008, 12:03:02 PM9/4/08
to
> maybe firls could be of help

thanks.
you mean the function "firls"?

Rajiv Singh

unread,
Sep 4, 2008, 12:14:59 PM9/4/08
to
Hi Ben,
Could you outline your steps with using System Identification Toolbox? It
should be possible to represent your data using IDFRD object and then create
a transfer function from it using functions such as PEM and OE.

Rajiv

"Ben Wu" <wushi...@gmail.com> wrote in message

news:g9p0rm$o6j$1...@fred.mathworks.com...

David

unread,
Sep 4, 2008, 12:22:01 PM9/4/08
to
"Ben Wu" <wushi...@gmail.com> wrote in message
<g9p0rm$o6j$1...@fred.mathworks.com>...

> > maybe firls could be of help
>
> thanks.
> you mean the function "firls"?

yes, with that i think you could take your measured
response curve and get the coefficients for an fir filter
to pass the sound through to get the response of your mic.

Ben Wu

unread,
Sep 4, 2008, 2:58:02 PM9/4/08
to
"Rajiv Singh" <rajiv...@msn.com> wrote in message
<g9p1i4$3ge$1...@fred.mathworks.com>...


Sure. Thanks for reply.
I have three vectors: magnitude, phase, frequency. I import
these data as freq.frequency(amp/phase). Then I estimate it
by using spectral model. Finally, I get IDFRD model and do
not what to do next.


Rajiv Singh

unread,
Sep 5, 2008, 10:55:28 AM9/5/08
to
Suppose you have mag/phase/frequency data. First create an IDFRD object to
represent this data:

H = mag.*exp(j*phase);
G = idfrd(H,w); %w is fequency in rad/s
(make sure the phase is in rad.)

Then you may estimate paramteric models using G as data. If you want
continuous-time models, you can set the sample time to zero in G (G.Ts=0),
or use "process models" (see M4 below).

M1 = oe(G, [2 2 1]); %get output error model: y = B/F*u+e, with 2 poles and
one zero
M2 = pem(G,4); % 4th order state-space model
M3 = arx(G, [2 2 1]); %arx model: Ay = Bu+e
M4 = pem(G,'p2dz'); % get a continuous-time process model

Note:
1. Commands such as ARX, OE, PEM ordinarily create discrete-time models. If
you want continuous-time models, you can either set G.Ts to 0 or use D2C on
the discrete model after estimation.

2. The model M4 above is "process model" which is basically a
continuous-time transfer function. It has the advantage that it allows delay
estimation. Its limitation is that is only allows low-order transfer
function estimation (3 or fewer poles, one zero, input delay and
integrator). G.Ts must be non-zero for estimating this model. Look up help
for IDPROC for more information.

3. All of these models can be imported into Simulink using the IDMODEL block
that is part of System Identification Toolbox block library.

4. You can convert these models into LTI objects, such as a trasnfer
function by using "tf" command, as in: mod = tf(M1('m')); The LTI model can
be imported into SImulink using the LTI block of Control System Toolbox.

5. You can also extract numerator and denominator coefficients for any of
these models using "tfdata", as in: [num, den] = tfdata(M1, 'v'); The "num"
and "den" values can be used in core Simulink's "Transfer fcn" and "Discrete
transfer fcn" blocks. There are also continuous and discrete state space
blocks for representing a LTI system using state-space matrices. Use
"ssdata" function to extract state-space matrices from any estimated model.

So you have several options to estimate models and also several options for
importing results into Simulink.

Rajiv

"Ben Wu" <wushi...@gmail.com> wrote in message

news:g9pb3q$pmi$1...@fred.mathworks.com...

Ben Wu

unread,
Sep 10, 2008, 10:26:02 PM9/10/08
to
"Rajiv Singh" <rajiv...@msn.com> wrote in message <g9rh90$sh0$1...@fred.mathworks.com>...

Thanks so much.But the transfer function I got all have poles>0. So, they are unstable.For example, I got Continuous-time IDPOLY model:
y(t) = [B(s)/F(s)]u(t) + e(t)
B(s) = 355.2 s + 3.487e006
F(s) = s^2 - 7283 s + 5.451e008
I tried other orders and got poles>0.

Ben Wu

unread,
Sep 10, 2008, 11:14:02 PM9/10/08
to
I find out there is a toolbox in matlab called Frequency Domain System Identification Toolbox(FDIDENT).

http://www.mathworks.com/products/connections/product_main.html?prod_id=309

http://matlab.gamax.hu/english/products/?article_hid=219

but it is not free.

Ben Wu

unread,
Sep 10, 2008, 11:14:02 PM9/10/08
to

David

unread,
Sep 11, 2008, 6:04:02 AM9/11/08
to
"Ben Wu" <wushi...@gmail.com> wrote in message <gaa2dq$fm6$1...@fred.mathworks.com>...

unfortunately many of the good things in life aren't free.

Rajiv Singh

unread,
Sep 11, 2008, 9:13:47 AM9/11/08
to
I don't know about the nature of your data (you may want to verify the units
of magnitude and phase data), but you may try using Focus='stability' during
estimation which forces the returned model to be stable:

model = oe(G,[2 2 1],'foc','stab');

The process models (idproc) are always stable.

Rajiv

"Ben Wu" <wushi...@gmail.com> wrote in message

news:ga9vjq$fko$1...@fred.mathworks.com...

Ben Wu

unread,
Sep 11, 2008, 10:51:02 AM9/11/08
to
"Rajiv Singh" <rajiv...@msn.com> wrote in message <gab5ib$pt2$1...@fred.mathworks.com>...

Yes, that makes transfer function stable. But the thing is that the phase response is not correct now.

Gary Pratt

unread,
Nov 17, 2008, 5:45:04 PM11/17/08
to

> H = mag.*exp(j*phase);
> G = idfrd(H,w); %w is fequency in rad/s
> (make sure the phase is in rad.)
>
> Then you may estimate paramteric models using G as data. If you want
> continuous-time models, you can set the sample time to zero in G (G.Ts=0),
> or use "process models" (see M4 below).
>
> M1 = oe(G, [2 2 1]); %get output error model: y = B/F*u+e, with 2 poles and
> one zero
> M2 = pem(G,4); % 4th order state-space model
> M3 = arx(G, [2 2 1]); %arx model: Ay = Bu+e
> M4 = pem(G,'p2dz'); % get a continuous-time process model

My version of Matlab doesn't seem to accept IDFRD objects for oe, pem, or arx. I'm using version MatLab 6.5 and the system identification toolbox version 5.0. pem() complains that OutputData must be a 2D matrix. arx() complains that NN must be the same number of columns as inputs. Am I missing a step, or do I need to user a newer version matlab?

Rajiv Singh

unread,
Nov 19, 2008, 12:18:06 PM11/19/08
to
Version 6.0 of System Identification Toolbox introduced frequency domain
identification. So it will not work with version 5.0

Rajiv


"Gary Pratt" <gp_remo...@wi.rr.com> wrote in message
news:gfss5g$ja$1...@fred.mathworks.com...

0 new messages