Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Z Transform (ztrans)

Subject: Z Transform (ztrans)

From: kamuran turksoy

Date: 7 Mar, 2012 20:20:17

Message: 1 of 10

Hi everybody,

i have a transfer function in s domain and i want to convert to z domain. I use ztrans function:

syms s z t

f=(6-2*t*s)/(6+4*s*t+(s*t)^2);
ztrans(f,s,z)

ans =
 
6*ztrans(1/(s^2*t^2 + 4*s*t + 6), s, z) + 2*t*z*diff(ztrans(1/(s^2*t^2 + 4*s*t + 6), s, z), z)

However i want to see the result. I used simple, expand, pretty functions to see it but none of them worked.

Can anybody tell me how can i see the result?


Regards

Subject: Z Transform (ztrans)

From: khadidja

Date: 7 Mar, 2012 23:38:18

Message: 2 of 10

"kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <jj8fu1$576$1@newscl01ah.mathworks.com>...
> Hi everybody,
>
> i have a transfer function in s domain and i want to convert to z domain. I use ztrans function:
>
> syms s z t
>
> f=(6-2*t*s)/(6+4*s*t+(s*t)^2);
> ztrans(f,s,z)
>
> ans =
>
> 6*ztrans(1/(s^2*t^2 + 4*s*t + 6), s, z) + 2*t*z*diff(ztrans(1/(s^2*t^2 + 4*s*t + 6), s, z), z)
>
> However i want to see the result. I used simple, expand, pretty functions to see it but none of them worked.
>
> Can anybody tell me how can i see the result?
>
>
> Regards

have you tried to type ztrans on matlab? it doesn't exist

Subject: Z Transform (ztrans)

From: kamuran turksoy

Date: 7 Mar, 2012 23:47:13

Message: 3 of 10

What you mean, it does not exits? here is function:

http://www.mathworks.com/help/toolbox/symbolic/ztrans.html

Subject: Z Transform (ztrans)

From: khadidja

Date: 8 Mar, 2012 00:01:41

Message: 4 of 10

"kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message <jj8s21$ffn$1@newscl01ah.mathworks.com>...
> What you mean, it does not exits? here is function:
>
> http://www.mathworks.com/help/toolbox/symbolic/ztrans.html


yes i saw it,in the last version of matlab, i don't have it with matlab 7.8
i'll try to help you because i work also on this

Subject: Z Transform (ztrans)

From: Nasser M. Abbasi

Date: 8 Mar, 2012 02:55:12

Message: 5 of 10

On 3/7/2012 2:20 PM, kamuran turksoy wrote:
> Hi everybody,
>
> i have a transfer function in s domain and i want to convert to z domain.
>I use ztrans function:
>
> syms s z t
>
> f=(6-2*t*s)/(6+4*s*t+(s*t)^2);
> ztrans(f,s,z)
>

ztrans takes as input f[n] and returns F[z], the Z transform of
f[n], defined as
      
               F[z]= SUM{ f[n] z^-n }

So, I do not know why you are applying the ztransform to the
laplace transform of a function.

And why you have 't' in your F(s), I do not understand. F(s) is
a function of 's' only. It is a transform of a time signal.

So, I have no idea what you are really doing here. If I knew better
I can try to help.

But the idea is this: To go from 's' domain to 'z' domain,
start by taking the inverse laplace transform, this gets you
back to time domain. Now replace 't' by n*T where T is the sampling
period. Now you have f[n], a discrete time sequence, now you can
go to the Z transform using ztran on f[n]. This is one way to do it.

--Nasser

Subject: Z Transform (ztrans)

From: Steven_Lord

Date: 8 Mar, 2012 15:01:38

Message: 6 of 10



"khadidja " <files@mathworks.com> wrote in message
news:jj8st5$hu4$1@newscl01ah.mathworks.com...
> "kamuran turksoy" <kamuranturksoy@gmail.com> wrote in message
> <jj8s21$ffn$1@newscl01ah.mathworks.com>...
>> What you mean, it does not exits? here is function:
>>
>> http://www.mathworks.com/help/toolbox/symbolic/ztrans.html
>
>
> yes i saw it,in the last version of matlab, i don't have it with matlab
> 7.8

That suggests that you previously had an installation that included Symbolic
Math Toolbox, but your current installation does not. You can check this for
your current installation with the VER function.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Z Transform (ztrans)

From: kamuran turksoy

Date: 8 Mar, 2012 17:38:37

Message: 7 of 10

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jj972h$qam$1@speranza.aioe.org>...
> On 3/7/2012 2:20 PM, kamuran turksoy wrote:
> > Hi everybody,
> >
> > i have a transfer function in s domain and i want to convert to z domain.
> >I use ztrans function:
> >
> > syms s z t
> >
> > f=(6-2*t*s)/(6+4*s*t+(s*t)^2);
> > ztrans(f,s,z)
> >
>
> ztrans takes as input f[n] and returns F[z], the Z transform of
> f[n], defined as
>
> F[z]= SUM{ f[n] z^-n }
>
> So, I do not know why you are applying the ztransform to the
> laplace transform of a function.
>
> And why you have 't' in your F(s), I do not understand. F(s) is
> a function of 's' only. It is a transform of a time signal.
>
> So, I have no idea what you are really doing here. If I knew better
> I can try to help.
>
> But the idea is this: To go from 's' domain to 'z' domain,
> start by taking the inverse laplace transform, this gets you
> back to time domain. Now replace 't' by n*T where T is the sampling
> period. Now you have f[n], a discrete time sequence, now you can
> go to the Z transform using ztran on f[n]. This is one way to do it.
>
> --Nasser

My fault, i should not use t in f(s) function. I am clarify now

syms s z tao

f=(6-2*tao*s)/(6+4*s*tao+(s*tao)^2);
ztrans(f,s,z);

Actually i have tried the way you suggested. First i took inverse laplace then i took z transporm of function of t. And it worked. But i found a problem there. Because when i use inverse laplace then ztrans and then when i use the value of tao i get a discrete transfer function. However before taking inverse laplace when i put value of tao and then use c2d for same sampling time, results are not same. And seems the one i get from c2d is correct. Here why i try ztrans because i want to find parameter tao, in case when i assume i know tao and i substitute it, results are different.

Subject: Z Transform (ztrans)

From: Nasser M. Abbasi

Date: 8 Mar, 2012 18:57:45

Message: 8 of 10

On 3/8/2012 11:38 AM, kamuran turksoy wrote:

>
> My fault, i should not use t in f(s) function. I am clarify now
>
> syms s z tao
>
> f=(6-2*tao*s)/(6+4*s*tao+(s*tao)^2);
> ztrans(f,s,z);
>

You are doing the same mistake. Taking the Z transform of a Laplace transform,
which makes no sense. And I do not understand what tao is? is 'f' the Laplace
transform? then it is a function of 's', not 't' and not 'tao'. I do not
know why you keep putting these in there for.

> Actually i have tried the way you suggested. First i took inverse laplace then
>i took z transporm of function of t.

No, that is not what I said. You can't apply the Z transform on a continouse
time signal. It has to be sampled signal. discrete signal. So, you need to
first replace 't' by 'n*T' where T is the sampling period. i.e you need
to first sample it.

>And it worked.

How could it work?

>But i found a problem there. Because when i use inverse laplace then
>ztrans and then when i use the value of tao i get a discrete transfer
>function. However before taking inverse laplace when i put value of
>tao and then use c2d for same sampling time, results are not same.
>And seems the one i get from c2d is correct. Here why i try ztrans because
>i want to find parameter tao, in case when i assume i know tao and i
>substitute it, results are different.

I am not following you. I am not really sure what is it you are trying
to do. Do you want to obtain Z transform and are given the Laplace transform?

If so, what I said before is one way. (replace t by n*T and then do ztran,
using 'n' as the independent variable).

Here is another way:
given F(s), we want Z transform.
----------------------
s=tf('s')
sys=F(s) % write here you laplace transform
sysd=c2d(sys,T,'zoh') %where T is the sampling period, a number
                       %this gives you the Z transform

but note that here I used zero order hold to sample.

--Nasser

Subject: Z Transform (ztrans)

From: kamuran turksoy

Date: 8 Mar, 2012 19:31:39

Message: 9 of 10

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jjavf7$h7r$1@speranza.aioe.org>...
> On 3/8/2012 11:38 AM, kamuran turksoy wrote:
>
> >
> > My fault, i should not use t in f(s) function. I am clarify now
> >
> > syms s z tao
> >
> > f=(6-2*tao*s)/(6+4*s*tao+(s*tao)^2);
> > ztrans(f,s,z);
> >
>
> You are doing the same mistake. Taking the Z transform of a Laplace transform,
> which makes no sense. And I do not understand what tao is? is 'f' the Laplace
> transform? then it is a function of 's', not 't' and not 'tao'. I do not
> know why you keep putting these in there for.
>
> > Actually i have tried the way you suggested. First i took inverse laplace then
> >i took z transporm of function of t.
>
> No, that is not what I said. You can't apply the Z transform on a continouse
> time signal. It has to be sampled signal. discrete signal. So, you need to
> first replace 't' by 'n*T' where T is the sampling period. i.e you need
> to first sample it.
>
> >And it worked.
>
> How could it work?
>
> >But i found a problem there. Because when i use inverse laplace then
> >ztrans and then when i use the value of tao i get a discrete transfer
> >function. However before taking inverse laplace when i put value of
> >tao and then use c2d for same sampling time, results are not same.
> >And seems the one i get from c2d is correct. Here why i try ztrans because
> >i want to find parameter tao, in case when i assume i know tao and i
> >substitute it, results are different.
>
> I am not following you. I am not really sure what is it you are trying
> to do. Do you want to obtain Z transform and are given the Laplace transform?
>
> If so, what I said before is one way. (replace t by n*T and then do ztran,
> using 'n' as the independent variable).
>
> Here is another way:
> given F(s), we want Z transform.
> ----------------------
> s=tf('s')
> sys=F(s) % write here you laplace transform
> sysd=c2d(sys,T,'zoh') %where T is the sampling period, a number
> %this gives you the Z transform
>
> but note that here I used zero order hold to sample.
>
> --Nasser

Basically i want to obtain z domain of a given transfer function in s domain. I agree with the way you suggest but results from two ways are different. Let me give you an example. I will use same function and this time i will give a value to tao as 4

syms s z tao

f=(6-2*tao*s)/(6+4*s*tao+(s*tao)^2);
i_f=ilaplace(f,s,t); % take laplace inverse, convert s domain to s
z_f=ztrans(i_f,t,z); % take z transform, convert from t domain to z
z_f_d=subs(z_f,tao,4); % substitute 4 instead of tao
z_f_d=simplify(z_f_d) % simplify function
...
...
z_f_d=

 -5.4366 + 7.13 z^-1
---------------------------------------
10.8731 -12.37z^-1 +4z^-2


Now i will use same function for second way. again tao=4

s=tf('s');
F=(6-8*s)/(6+16*s+16*s^2;
sysd=c2d(F,1,'zoh')

Transfer function:
  -0.163 z + 0.3928
------------------------------
z^2 - 1.138 z + 0.3679

And i just found instead 'zoh' if i use 'imp' it give same result as first method.
sysd=c2d(F,1,'imp')

Transfer function:
 -0.5 z^2 + 0.6557 z
----------------------
z^2 - 1.138 z + 0.3679

And i want to use result i got from zero hold sampling way. So how can i use inverse lapce-ztrans way but with zero hold sampling. Because result i get from sysd=c2d(F,1,'zoh') is the one i need. Here before calculation i assumed i know tao, thus i could use c2d but in reality i do not know before these calculation. So i have to use ilaplace-ztrans way.

Subject: Z Transform (ztrans)

From: Nasser M. Abbasi

Date: 9 Mar, 2012 02:00:09

Message: 10 of 10

On 3/8/2012 1:31 PM, kamuran turksoy wrote:


>> "Nasser M. Abbasi"<nma@12000.org> wrote in message<jjavf7$h7r$1@speranza.aioe.org>...
>> Here is another way:
>> given F(s), we want Z transform.
>> ----------------------
>> s=tf('s')
>> sys=F(s) % write here you laplace transform
>> sysd=c2d(sys,T,'zoh') %where T is the sampling period, a number
>> %this gives you the Z transform
>>
>> but note that here I used zero order hold to sample.


>
> Basically i want to obtain z domain of a given transfer function in s domain.
>I agree with the way you suggest but results from two ways are different.
>Let me give you an example. I will use same function and this time
>i will give a value to tao as 4
>
> syms s z tao
>
> f=(6-2*tao*s)/(6+4*s*tao+(s*tao)^2);
> i_f=ilaplace(f,s,t); % take laplace inverse, convert s domain to s

so far so good.

> z_f=ztrans(i_f,t,z); % take z transform, convert from t domain to z

even though below you used sampling period of ONE (which is
a special case), still the above is a very sloppy way of doing things.

> z_f_d=subs(z_f,tao,4); % substitute 4 instead of tao
> z_f_d=simplify(z_f_d) % simplify function

You should first convert the continouse time signal to discrete time
signal before passing it to z-transform, to be clear what you
are doing, like this:

clear all
syms s z n t tao
f = (6-2*tao*s)/(6+4*s*tao+(s*tao)^2);
i_f = ilaplace(f,s,t);
T = 1;
f_n = subs(i_f,t,n*T);
z_f = ztrans(f_n,n,z);
z_f = subs(z_f,tao,4)


> ...
> ...
> z_f_d=
>
> -5.4366 + 7.13 z^-1
> ---------------------------------------
> 10.8731 -12.37z^-1 +4z^-2
>

Ok so far.

> Now i will use same function for second way. again tao=4
>
> s=tf('s');
> F=(6-8*s)/(6+16*s+16*s^2;
> sysd=c2d(F,1,'zoh')
>
> Transfer function:
> -0.163 z + 0.3928
> ------------------------------
> z^2 - 1.138 z + 0.3679
>
> And i just found instead 'zoh' if i use 'imp' it give same result as first method.
> sysd=c2d(F,1,'imp')
>
> Transfer function:
> -0.5 z^2 + 0.6557 z
> ----------------------
> z^2 - 1.138 z + 0.3679
>
> And i want to use result i got from zero hold sampling way.

Why not use 'imp' if that gives you what you want?

>So how can i use inverse lapce-ztrans way but with zero hold sampling.

I do not know right now.

>Because result i get from sysd=c2d(F,1,'zoh') is the one i need.
>Here before calculation i assumed i know tao, thus i could use c2d but
>in reality i do not know before these calculation. So i have
>to use ilaplace-ztrans way.

--Nasser

Tags for this Thread

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.

Contact us