Learn R Programming

control (version 0.2.5)

gensig: Generate periodic signal

Description

gensig generates a periodic signal. More useful when used in combination with lsim

Usage

gensig(signal, tau, tfinal, tsam)

Arguments

signal

A string input containing either values of: square, sin, cos, pulse in the following format:

'sq' or 'square' - Square wave

'si' or 'sine' - Sine wave

'co' or 'cos' - Cosine wave

'pu' or 'pulse' - Periodic pulse

tau

Duration of one period in seconds. Default is 5

tfinal

Duration of the signal in seconds. Default is 30

tsam

sampling time in seconds. Default is 0.01

Value

Returns a list of two single column matrices, u and t

u is the vector of signal values

t is the time vector of the signal

Details

gensig generates a periodic signal of the following types: square, sin, cos, pulse

Possible usage: gensig(signal)

See Also

lsim

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
 A square wave signal 
# }
# NOT RUN {
sig <-  gensig('square', 4, 10, 0.1)
plot(sig$t, sig$u, type = "l", col = "blue")
grid(5,5, col = "lightgray")

# }
# NOT RUN {
 A sine wave signal 
# }
# NOT RUN {
sig <-  gensig('sin')
plot(sig$t, sig$u, type = "l", col = "blue")
grid(5,5, col = "lightgray")

# }

Run the code above in your browser using DataLab