Filter löschen
Filter löschen

Define a function for a system using Symbolic Math Toolbox

1 Ansicht (letzte 30 Tage)
Elias
Elias am 24 Jan. 2011
I want just to define a function y(t).It is the output of my system and I want to use it in a controller as
y(t),y(t+1)
or so and do a Z transformation.
I do not want to define it as:
y=inline('something'), only y(t)
with undefined content.

Antworten (5)

Christopher Creutzig
Christopher Creutzig am 25 Jan. 2011
For the symbolic toolbox, you probably should use explicit sym calls, as in the following:
>> syms t z
>> evalin(symengine, 'transform::ztrans::addpattern(y(t), t, z, Y(z))')
>> ztrans(sym('y(t+1)'), t, z)
ans =
z*Y(z) - z*y(0)
  2 Kommentare
Paulo Silva
Paulo Silva am 25 Jan. 2011
Are you sure that ans is correct?
Christopher Creutzig
Christopher Creutzig am 26 Jan. 2011
Y(z) = sum(y(k)/z^k, k=0..infinity)
z*Y(z) = z*sum(y(k)/z^k, k=0..infinity)
= sum(y(k)/z^(k-1), k=0..infinity)
= sum(y(k+1)/z^k, k=-1..infinity)
= sum(y(k+1)/z^k, k=0..infinity) + z*y(0)
Yes, I think the answer is correct.

Melden Sie sich an, um zu kommentieren.


Matt Fig
Matt Fig am 24 Jan. 2011
What use could an undefined function be? If you want your function to return nothing, then:
y = @(t) [];
would do the trick. Then from the command line:
>> y(5)
ans =
[]
>> y(2:6)
ans =
[]
  1 Kommentar
Elias
Elias am 24 Jan. 2011
I have an equation with a lot of calculations with y(t),y(t+1),u(t),u(t+1)
I want to be able to do a Z transformation. eg Z(y(t))=Y(z) and Z(y(t+1)=zY(z))

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 24 Jan. 2011
You would need the Symbolic Toolkit to do this, and you would have to do the transforms using the toolkit facilities, as most Matlab routines do not know how to work with symbolic variables.

Paulo Silva
Paulo Silva am 25 Jan. 2011
syms z t
%funt='1'; %step
%funt='t'; %ramp
funt='t+1'; %shifted ramp
%funt='t^2'; %parabole
fz=@(x) ztrans(sym(x), t, z);
Flaplace=laplace(sym(funt))
ZTranform=fz(funt)
ZTranformSimplified=simplify(fz(funt))

Paulo Silva
Paulo Silva am 25 Jan. 2011
In a function, I didn't called it just y to avoid problems with variables having the same name of files, but you can call it y and do y('t+1') instead of convCSZ('t+1'), calling it like this [ZTranform Flaplace]=convCSZ('t+1') will also give of the laplace transform :) , [ZTranform Flaplace ZTranformSimplified]=convCSZ('t+1') gives also the simplified version of the z transform :)
function [ZTranform Flaplace ZTranformSimplified]=convCSZ(funt)
syms t z
%funt='1'; %step
%funt='t'; %ramp
%funt='t+1'; %shifted ramp
%funt='t^2'; %parabole
%y=inline(funt)
fz=@(x) ztrans(sym(x), t, z);
Flaplace=laplace(sym(funt));
ZTranform=fz(funt);
ZTranformSimplified=simplify(fz(funt));

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by