Skip to content

Triangle in AnalogSignal.m is phase shifted relative to sin, cos #10

Description

@stiber

The triangle waveform starts at its lowest value, rather than its midpoint, like a sine or cosine. This basically represents a phase shift; it is best that that be avoided.

function y = triangle(f, t)
% TRIANGLE Generate a triangle wave with values in range [0, 1]
% Y = TRIANGLE(F, T)
% F = number of triangles per second
% T = array of times
y = min(rem(t,1/f)/(1/(2*f)), ((1/f)-rem(t,1/f))/(1/(2*f)));
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions