필터 지우기
필터 지우기

Define a function for a system using Symbolic Math Toolbox

조회 수: 1 (최근 30일)
Elias
Elias 2011년 1월 24일
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
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
Paulo Silva
Paulo Silva 2011년 1월 25일
Are you sure that ans is correct?
Christopher Creutzig
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
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에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by