Mu Analysis and Synthesis Toolbox | ![]() ![]() |
Generate VARYING matrix functions
Syntax
Description
siggen
is a general purpose signal generator. You can provide a timebase with the argument t
, and the function to be evaluated with the first argument (a string), function(t)
. The output, y
, will be a VARYING matrix. t
could also be VARYING, in which case the timebase is the independent variables contained in t
.
function(t)
is not necessarily dependent on t
. In the cases where it doesn't
depend on t
, siggen
can be slow. This is because function
is evaluated with a MATLAB eval
call for every element in t
. For example, consider generating a random vector. The command
t
. To a 2 x 1 VARYING matrix of random values, you can use the command
This is slow because 101 evaluations of rand(2,1)
are performed in a MATLAB for
loop. For vectors of random signals, a much faster alternative is to use vpck
with a random matrix of the appropriate size. In the above example this would be
Examples
The first example illustrates what is perhaps the most common use of siggen
. A single-input single-output signal is created from MATLAB mathematical functions. It is important to use t
as the independent variable in the function string.
timebase = [0:0.05:10]; y1 =siggen
('exp(0.1*t
) -sin
(3*t
)',timebase);minfo
(y1) varying:201pts
1 rows1 colsvplot
(y1) title('siggen
example: function depends ont
')
t
, and is executed at each instance of t
. This example is included to illustrate that the function string need not depend on t
. In practice the string rand(size(t))
is orders of magnitude faster than rand
.
y2 = siggen('rand',y1); minfo(y2) varying:201 pts1 rows1 cols vplot(y2) title('siggen example: function independent of t')
The use of siggen
is not restricted to single-input, single-output signals. The following example creates a 2 x 2 VARYING matrix. In this example the matrix elements are all functions of t
and the results plotted in the figure. They could equally well have all been independent of t
, for example 'rand(3,2)'
could be the function string. (Note that they must all be one type or the other (this restriction does not apply if t
is a single number).
func = '[t
/max(t
) 2*cos
(3*t
+0.2); 2+0.1*sin
(2*t
) '; func = [func ' sqrt(t
)+0.3*rand(size(t))
]']; y3 =siggen
(func,timebase);minfo
(y3) varying:201pts
2 rows2 colsvplot
(y3) title('Siggen
example: 2 x 2 varying matrix')
siggen
cannot generate stair-step signals with user-specified values. You can do this however (for single-input/single-output signals) using the command vpck
or the µ-Tools commmand step_tr
. Vectors of signals can be created with vpck
and abv
. The following example demonstrates the use of vpck
. vinterp
is used to plot a meaningful representation of the signal.
y4 = vpck([0:10]',[0:2:20]'); minfo(y4) varying:11 pts1 rows1 cols vplot(vinterp(y4,0.1)) title('Siggen example: step function')
See Also
cos_tr
, sin_tr
, step_tr
, vpck
, vinterp
![]() | sel, reordsys | simgui | ![]() |