Borrar filtros
Borrar filtros

Define a function for a system using Symbolic Math Toolbox

1 visualización (últimos 30 días)
Elias
Elias el 24 de En. de 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.

Respuestas (5)

Christopher Creutzig
Christopher Creutzig el 25 de En. de 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 comentarios
Paulo Silva
Paulo Silva el 25 de En. de 2011
Are you sure that ans is correct?
Christopher Creutzig
Christopher Creutzig el 26 de En. de 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.

Iniciar sesión para comentar.


Matt Fig
Matt Fig el 24 de En. de 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 comentario
Elias
Elias el 24 de En. de 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))

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 24 de En. de 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 el 25 de En. de 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 el 25 de En. de 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));

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by