SquareWave#
- class SquareWave(options)#
Bases:
PeriodicWaveformSquareWavegenerates square wave signals with configurable duty cycle.Creates periodic square wave signals with adjustable amplitude, frequency, phase, and duty cycle. The waveform alternates between high and low levels based on the duty cycle percentage. Inherits from
PeriodicWaveform.Example1:
% Create a 50% duty cycle square wave square = SquareWave(frequency = 1000, amplitude = 2.0, duration = 0.01); square.plot();
Example2:
% Create a 25% duty cycle square wave square = SquareWave(frequency = 500, amplitude = 1.0, dutyCycle = 0.25); square.plotOneCycle();
- Constructor Summary
- SquareWave(options)#
Construct a SquareWave object.
- Parameters:
samplingRate (
double, optional) – Sampling rate in Hz (default: [])startTime (
double, optional) – Start time in seconds (default: 0)duration (
double, optional) – Duration in seconds (default: [])amplitude (
double, optional) – Peak-to-peak amplitude (default: [])offset (
double, optional) – DC offset (default: 0)frequency (
double, optional) – Frequency in Hz (default: [])phase (
double, optional) – Phase in radians (default: 0)dutyCycle (
double, optional) – Duty cycle fraction [0,1] (default: 0.5)
- Property Summary
- DutyCycle double { mustBeGreaterThanOrEqual(DutyCycle,0), mustBeLessThanOrEqual(DutyCycle,1) } = 0.5#
Fraction of each period the waveform stays at its high level.
- Method Summary
- TimeFunc()#
Get the time function for the square wave.
Creates a function handle that generates square wave values based on the configured amplitude, frequency, phase, and duty cycle. Implements the abstract
TimeFunc()method fromWaveform.- Returns:
Function that takes time array and returns square wave values
- Return type:
function_handle