Define a function for a system using Symbolic Math Toolbox

1 次查看(过去 30 天)
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.

回答(5 个)

Christopher Creutzig
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 个评论
Christopher Creutzig
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.

请先登录,再进行评论。


Matt Fig
Matt Fig 2011-1-24
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 个评论
Elias
Elias 2011-1-24
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))

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2011-1-24
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 2011-1-25
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 2011-1-25
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));

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by