0% found this document useful (0 votes)
131 views6 pages

TFCHK Dded

para ustedes hay ba nfghnfg tghrthtrhrthrthrthh rt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views6 pages

TFCHK Dded

para ustedes hay ba nfghnfg tghrthtrhrthrthrthh rt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

tfchk

(/tools/hpmatlab/toolbox/signal/tfchk.m)
Function Synopsis
[numc,denc] = tfchk(num,den)

Help text
TFCHK

Check for proper transfer function.


[NUMc,DENc] = TFCHK(NUM,DEN) returns equivalent transfer
function
numerator and denominator where LENGTH(NUMc) = LENGTH(DENc) if
the transfer function NUM,DEN are proper. Prints an error
message
if not.

Cross-Reference Information
This function calls

disp

/tools/hpmatlab/toolbox/matlab/general/disp.m

end

/tools/hpmatlab/toolbox/matlab/lang/end.m

error

/tools/hpmatlab/toolbox/matlab/lang/error.m

function

/tools/hpmatlab/toolbox/matlab/lang/function.m

if

/tools/hpmatlab/toolbox/matlab/lang/if.m

isempty

/tools/hpmatlab/toolbox/matlab/ops/isempty.m

return

/tools/hpmatlab/toolbox/matlab/lang/return.m

size

/tools/hpmatlab/toolbox/matlab/general/size.m

zeros

/tools/hpmatlab/toolbox/matlab/elmat/zeros.m

This function is called by

tf2zp

/tools/hpmatlab/toolbox/signal/tf2zp.m

for
(/tools/hpmatlab/toolbox/matlab/lang/for.m)

Help text
FOR

Repeat statements a specific number of times.


The general form of a FOR statement is:
FOR variable = expr, statement, ..., statement END
The columns of the expression are stored one at a time in
the variable and then the following statements, up to the
END, are executed. The expression is often of the form X:Y,
in which case its columns are simply scalars. Some examples
(assume N has already been assigned a value).
FOR I = 1:N,
FOR J = 1:N,
A(I,J) = 1/(I+J-1);
END
END
FOR S = 1.0: -0.1: 0.0, END steps S with increments of -0.1
FOR E = EYE(N), ... END sets E to the unit N-vectors.

function
(/tools/hpmatlab/toolbox/matlab/lang/function.m)

Help text
FUNCTION Function M-files.
New functions may be added to MATLAB's vocabulary if they
are expressed in terms of other existing functions. The
commands and functions that comprise the new function must
be put in a file whose name defines the name of the new
function, with a filename extension of '.m'. At the top of
the file must be a line that contains the syntax definition
for the new function. For example, the existence of a file
on disk called STAT.M with:
function [mean,stdev] = stat(x)
n = length(x);
mean = sum(x) / n;
stdev = sqrt(sum((x - mean).^2)/n);
defines a new function called STAT that calculates the
mean and standard deviation of a vector. The variables
within the body of the function are all local variables.
See SCRIPT for procedures that work globally on the workspace.
See also ECHO, SCRIPT.

length
(/tools/hpmatlab/toolbox/matlab/general/length.m)

Help text
LENGTH Number of components of a vector.
LENGTH(X) returns the length of vector X.
to MAX(SIZE(X)).

It is equivalent

if
(/tools/hpmatlab/toolbox/matlab/lang/if.m)

Help text
IF

of

Conditionally execute statements.


The general form of an IF statement is:
IF variable, statements, END
The statements are executed if the real part of the variable
has all non-zero elements. The variable is usually the result
expr rop expr where rop is ==, <, >, <=, >=, or ~=.
For example:

IF I == J
A(I,J) = 2;
ELSEIF ABS(I-J) == 1
A(I,J) = -1;
ELSE
A(I,J) = 0;
END

error
(/tools/hpmatlab/toolbox/matlab/lang/error.m)

Help text
ERROR

Display message and abort function.


ERROR('MSG') displays the text MSG and causes an error exit
from an M-file to the keyboard. If the string is an empty
matrix, no action is taken.

funcin [numc, denc] = tfchk (num, den)


% TFCHK Compruebe si la funcin de transferencia adecuado.
% [Numc, denc] = TFCHK (num, den) devuelve la funcin de transferencia
equivalente
% Numerador y el denominador, donde LONGITUD (numc) = longitud (denc)
si
% De la funcin de transferencia de NUM, DEN son propias. Imprime un
mensaje de error
% si no.
% Arcilla M. Thompson 06/26/90
% Derechos de autor (c) 1986-1994 por The MathWorks, Inc.
% $ Revision: 1.14 $ $ Fecha: 1994/01/25 17:55:56 $
[Nn, mn] = tamao (num);
[Sf, MD] = tamao (den);
Comprobar% para las matrices vacas
si IsEmpty (num) | IsEmpty (den),
disp (Advertencia:. polinomios funcin de transferencia estn vacos
');
regreso;
fin
% Asegrese de DEN es un vector fila, NUM se supone que es en filas.
si (~ ((nd == 1) | (md == 1))), error ( 'El denominador debe ser un
vector.'); fin
si (nd ~ = 1) y (md == 1), error ( 'El denominador debe ser un vector
fila.'); fin
si (MN> md), error ( 'Funcin de transferencia no adecuada.'); fin
Hacer NUM% y DEN longitudes iguales.

NUMC = [ceros (nn, md-mn), num];


denc = den;

function [yout,x,n] = dimpulse(a,b,c,d,iu,n)


%DIMPULSE Impulse response of discrete-time linear systems.
%
DIMPULSE(A,B,C,D,IU) plots the response of the discrete
system:
%
%
x[n+1] = Ax[n] + Bu[n]
%
y[n]
= Cx[n] + Du[n]
%
%
to an unit sample applied to the single input IU. The number
of
%
points is determined automatically.
%
%
DIMPULSE(NUM,DEN) plots the impulse response of the polynomial
%
transfer function G(z) = NUM(z)/DEN(z) where NUM and DEN
contain
%
the polynomial coefficients in descending powers of z.
%
%
DIMPULSE(A,B,C,D,IU,N) or DIMPULSE(NUM,DEN,N) uses the user%
supplied number of points, N. When invoked with left hand
%
arguments,
%
[Y,X] = DIMPULSE(A,B,C,D,...)
%
[Y,X] = DIMPULSE(NUM,DEN,...)
%
returns the output and state time history in the matrices Y and
X.
%
No plot is drawn on the screen. Y has as many columns as there
%
are outputs and X has as many columns as there are states.
%
%
See also: DSTEP,DINITIAL,DLSIM and IMPULSE.
%
%
%

J.N. Little 4-21-85


Revised CMT 7-31-90, ACWG 5-30-91
Copyright (c) 1986-93 by the MathWorks, Inc.

nargin = 6;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ADDED BY BTM


if nargin==0, eval('exresp(''dimpulse'');'), return,end
error(nargchk(2,6,nargin));
if (nargin==2),
% Transfer function without number of points
[num,den] = tfchk(a,b);
iu = 1;
[a,b,c,d] = tf2ss(num,den);
elseif (nargin==3),
% Transfer function with number of points
[num,den] = tfchk(a,b);
n = c;
iu = 1;
[a,b,c,d] = tf2ss(num,den);
elseif (nargin>=4)
error(abcdchk(a,b,c,d));
end
[ny,nu] = size(d);

if (nu*ny==0), x = []; n = []; if nargout~=0, yout=[]; end, return,


end
% Work out number of points if not supplied.
if nargin==4 | nargin==5 | nargin==2,
if isempty(a),
n = 3;
else
% The next line controls the number of samples in the
plot if N not specified
st=0.001; % Set settling time bound = 0.1%
[n,m]=size(b);
x0=(eye(n,n)-a)\(b*ones(m,1));
% Cater for pure integrator case
infind=find(~finite(x0));
x0(infind)=ones(length(infind),1);
n=dtimvec(a,b,c,x0,st);

end
if nargin==4
% Multivariable systems
[iu,nargin,y]=mulresp('dimpulse',a,b,c,d,n,nargout,0);
if ~iu, if nargout, yout = y; end, return, end
end
end
if (nargin <= 3)&(nargout <= 1),
% Transfer function description
y = dlsim(num,den,[1;zeros(n-1,1)]); % More efficient: uses
FILTER
else
if ~isempty(b), b=b(:,iu); end, d = d(:,iu);
[y,x] = dlsim(a,b,c,d,[1;zeros(n-1,1)]);
end
if nargout==0,
% With no output arguments, plot graph
status = ishold;
stairs([0:n-1],y)
hold on
plot([0,n-1],[0;0],':')
xlabel('No. of Samples')
ylabel('Amplitude')
if ~status, hold off, end
return % Suppress output
end
yout = y;

% Return hold to previous status

You might also like