Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: picewise linear warping function

Subject: picewise linear warping function

From: beda meda

Date: 17 May, 2008 17:18:01

Message: 1 of 3

Hi,
picewise linear warping function has following formula:

f(w) = a*w for 0<=w<w0
f(w) = a*w0 + ((pi-a*w0)/(pi-w0))*(w-w0) for w0<=w<=wb

where w is frequency, wb is boundary frequency, w0 is
breaking frequency and a is warping factor alpha.

Now, I want to draw this function for three alphas, a=1,
a=0.9 and a=1.1. I have wb=4 kHz (so w=1:4000) and w0=2.5
kHz. It's shame there is not possibility of placing image
here, so I will try to describe, what should be result. For
a=1 it's one linear functin for all w=1:4000. For a=1.1
there are two parts, first function is rising faster then
for a=1 till w0, and then it breaks and it should end in
same point as for a=1. For a=0.9 it's same, only first part
is rising slower then a=1, and when it breaks at w0 it goes
steeply up and also it should end in the same point as a=1
and a=1.1.

And now my problem - I tried to solve that by this way:

a=0.9;
w=(1:4000);
w0=2500;
n=zeros(4000,1);
for i=1:2499
    n(i)=a*w(i);
end
for i=2500:4000
    n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
end
plot(w,n)
hold on

a=1;
w=(1:4000);
w0=2500;
n=zeros(4000:1);
for i=1:2499
    n(i)=a*w(i);
end
for i=2500:4000
    n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
end
plot(w,n)

a=1.1;
w=(1:4000);
w0=2500;
n=zeros(4000:1);
for i=1:2499
    n(i)=a*w(i);
end
for i=2500:4000
    n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
end
plot(w,n)
hold off

But that doesn't work, nor a=1.1 nor a=0.9 are braking at w0
fast enough to end at the same point as a=1 and I don't know
why.

Does anyone know, what should be done different, or where is
mistake?

Thank you!

Subject: picewise linear warping function

From: Roger Stafford

Date: 17 May, 2008 23:13:01

Message: 2 of 3

"beda meda" <b.meda@centrum.cz> wrote in message <g0n409$8sd
$1@fred.mathworks.com>...
> Hi,
> picewise linear warping function has following formula:
>
> f(w) = a*w for 0<=w<w0
> f(w) = a*w0 + ((pi-a*w0)/(pi-w0))*(w-w0) for w0<=w<=wb
>
> where w is frequency, wb is boundary frequency, w0 is
> breaking frequency and a is warping factor alpha.
>
> Now, I want to draw this function for three alphas, a=1,
> a=0.9 and a=1.1. I have wb=4 kHz (so w=1:4000) and w0=2.5
> kHz. It's shame there is not possibility of placing image
> here, so I will try to describe, what should be result. For
> a=1 it's one linear functin for all w=1:4000. For a=1.1
> there are two parts, first function is rising faster then
> for a=1 till w0, and then it breaks and it should end in
> same point as for a=1. For a=0.9 it's same, only first part
> is rising slower then a=1, and when it breaks at w0 it goes
> steeply up and also it should end in the same point as a=1
> and a=1.1.
>
> And now my problem - I tried to solve that by this way:
>
> a=0.9;
> w=(1:4000);
> w0=2500;
> n=zeros(4000,1);
> for i=1:2499
> n(i)=a*w(i);
> end
> for i=2500:4000
> n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
> end
> plot(w,n)
> hold on
>
> a=1;
> w=(1:4000);
> w0=2500;
> n=zeros(4000:1);
> for i=1:2499
> n(i)=a*w(i);
> end
> for i=2500:4000
> n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
> end
> plot(w,n)
>
> a=1.1;
> w=(1:4000);
> w0=2500;
> n=zeros(4000:1);
> for i=1:2499
> n(i)=a*w(i);
> end
> for i=2500:4000
> n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
> end
> plot(w,n)
> hold off
>
> But that doesn't work, nor a=1.1 nor a=0.9 are braking at w0
> fast enough to end at the same point as a=1 and I don't know
> why.
>
> Does anyone know, what should be done different, or where is
> mistake?
>
> Thank you!
---------------------------
  What is the relationship between what you have called 'pi' and 'wb'? Unless
these are equal, the three values of 'n' will not match at 'wb'. To see this, just
write out the expression for n at w = wb and force it to be independent of a,
that is, set the coefficient of a to zero, and you will also be forced to set pi
equal to wb.

Roger Stafford

Subject: picewise linear warping function

From: beda meda

Date: 18 May, 2008 09:14:02

Message: 3 of 3

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
wrote in message <g0nopt$pne$1@fred.mathworks.com>...
> "beda meda" <b.meda@centrum.cz> wrote in message <g0n409$8sd
> $1@fred.mathworks.com>...
> > Hi,
> > picewise linear warping function has following formula:
> >
> > f(w) = a*w for 0<=w<w0
> > f(w) = a*w0 + ((pi-a*w0)/(pi-w0))*(w-w0) for w0<=w<=wb
> >
> > where w is frequency, wb is boundary frequency, w0 is
> > breaking frequency and a is warping factor alpha.
> >
> > Now, I want to draw this function for three alphas, a=1,
> > a=0.9 and a=1.1. I have wb=4 kHz (so w=1:4000) and w0=2.5
> > kHz. It's shame there is not possibility of placing image
> > here, so I will try to describe, what should be result. For
> > a=1 it's one linear functin for all w=1:4000. For a=1.1
> > there are two parts, first function is rising faster then
> > for a=1 till w0, and then it breaks and it should end in
> > same point as for a=1. For a=0.9 it's same, only first part
> > is rising slower then a=1, and when it breaks at w0 it goes
> > steeply up and also it should end in the same point as a=1
> > and a=1.1.
> >
> > And now my problem - I tried to solve that by this way:
> >
> > a=0.9;
> > w=(1:4000);
> > w0=2500;
> > n=zeros(4000,1);
> > for i=1:2499
> > n(i)=a*w(i);
> > end
> > for i=2500:4000
> > n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
> > end
> > plot(w,n)
> > hold on
> >
> > a=1;
> > w=(1:4000);
> > w0=2500;
> > n=zeros(4000:1);
> > for i=1:2499
> > n(i)=a*w(i);
> > end
> > for i=2500:4000
> > n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
> > end
> > plot(w,n)
> >
> > a=1.1;
> > w=(1:4000);
> > w0=2500;
> > n=zeros(4000:1);
> > for i=1:2499
> > n(i)=a*w(i);
> > end
> > for i=2500:4000
> > n(i)=a*w0+((pi-a*w0)/(pi-w0))*(w(i)-w0);
> > end
> > plot(w,n)
> > hold off
> >
> > But that doesn't work, nor a=1.1 nor a=0.9 are braking at w0
> > fast enough to end at the same point as a=1 and I don't know
> > why.
> >
> > Does anyone know, what should be done different, or where is
> > mistake?
> >
> > Thank you!
> ---------------------------
> What is the relationship between what you have called
'pi' and 'wb'? Unless
> these are equal, the three values of 'n' will not match at
'wb'. To see this, just
> write out the expression for n at w = wb and force it to
be independent of a,
> that is, set the coefficient of a to zero, and you will
also be forced to set pi
> equal to wb.
>
> Roger Stafford
>
I solved it at last. The problem was indeed in relationship
between pi and w and wb. The solution is very simple (as
always, when you know it):

a=0.9;
w=(1:4000);
w=w*(pi/4000);
w0=2500;
w=w0*(pi/4000);

And thats it:)

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics