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.
0 个评论
回答(5 个)
Christopher Creutzig
2011-1-25
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
2011-1-26
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
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 =
[]
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.
0 个评论
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))
0 个评论
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));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!