TriangleWave#
- class TriangleWave(options)#
Bases:
PeriodicWaveformTriangleWavegenerates a periodic triangle waveform.Creates a sine wave with specified amplitude, frequency, phase, and timing parameters. The waveform is zero outside the specified duration. Inherits from
PeriodicWaveform.Example1:
% Basic sine wave sine = SineWave(frequency = 1000, amplitude = 2.0, duration = 0.01); sine.plot();
Example2:
% Sine wave with phase offset sine = SineWave(frequency = 500, amplitude = 1.0, phase = pi/4); sine.plot();
- Constructor Summary
- TriangleWave(options)#
Construct a
TriangleWave.- Parameters:
samplingRate (
double, optional) – Sampling rate [Hz] (default: [])startTime (
double, optional) – Start time \(t_0\) [s] (default: 0)duration (
double, optional) – Duration \(T\) [s] (default: [])amplitude (
double, optional) – Waveform amplitude (default: [])offset (
double, optional) – DC offset (default: 0)frequency (
double, optional) – Frequency \(f\) [Hz] (default: [])phase (
double, optional) – Phase \(\phi\) [rad] (default: 0)
- Property Summary
- Balance double = 0.5#
- Method Summary
- TimeFunc()#
Get the time function for the sine wave.
Implements the abstract
TimeFunc()fromWaveformby returning \(f(t) = \mathbb{1}_{[t_0,t_0+T]}(t)\,(A/2\,\sin(2\pi f (t-t_0)+\phi)+\mathrm{offset})\).- Returns:
Function that takes time array and returns sine wave values
- Return type:
function_handle
Example:
sine = SineWave(frequency = 1000, amplitude = 1.0); func = sine.TimeFunc(); t = 0:0.001:0.01; y = func(t);