SquareWaveGenerator

SquareWaveGenerator

Diagram Context expand

    if isnumeric(dutyCycle) && (dutyCycle > 100 || dutyCycle < 0)

    error ('Duty Cycle must be a positive value less than 100');

    else;

    %dutyCycle=min(100,max(dutyCycle,0));

    end

    if isnumeric(period) && period <= 0

    error ('Period must be a positive value greater than 0');

    else;

    %period=max(0,period);

    end

    FD = period * dutyCycle / 100;

    SD = period * (100 - dutyCycle) / 100;

    if isnumeric(SD) && isnumeric(offset) && (offset > SD || offset < 0)

    error (['Offset must be a positive value less than ',num2str(SD)]);

    else;

    %Offset=max(0,min(Offset,SD));

    end

    [mF,nF] = size (FV);

    [mS,nS] = size (SV);

    if mS ~= mF || nF ~= nS

    if mF * nF == 1

    FV = FV * ones (mS, nS);

    elseif mS * nS == 1

    SV = SV * ones (mF, nF);

    else

    error ('Incompatible Dimensions for First and Second values', 0);

    end

    end