function a = set(a,varargin)
% SET Set IncWave properties and return the updated object

propertyArgIn = varargin;
while length(propertyArgIn) >= 2
    prop = propertyArgIn{1};
    val = propertyArgIn{2};
    propertyArgIn = propertyArgIn(3:end);
    switch prop
        case 'Type'
            a.Type = val;
            a = ComputeSpectrum(a);
        case 'A'
            a.A = val;
            a = ComputeSpectrum(a);
        case 'T'
            a.T = val;
            a = ComputeSpectrum(a);
        case 'g'
            a.g = val;
        case 'spectrum'
            a.spectrum = val;      
        case 'beta'
            a.beta = val;
        case 'phases'
            a.phases = val;
            a = ComputeSpectrum(a);
        case 'fmax'
            a.fmax = val;
            a.freq = a.fmin:(a.fmax-a.fmin)/(a.n_freq-1):a.fmax;
            a = ComputeSpectrum(a);
        case 'fmin'
            a.fmin = val;
            a.freq = a.fmin:(a.fmax-a.fmin)/(a.n_freq-1):a.fmax;
            a = ComputeSpectrum(a);          
        case 'n_freq'
            if(a.Type ~= 1)
              a.n_freq = val;
            else
                a.n_freq = 1;
            end
            a.freq = a.fmin:(a.fmax-a.fmin)/(a.n_freq-1):a.fmax;
            a = ComputeSpectrum(a);       
        case 'tau'
            if(val > 0)
              a.tau = a.T/val;  %Sets number of periods to ramp up over.
            else
              a.tau = 0;
            end
        otherwise
            error('Invalid IncWave property')
    end
end