classdef Signalgenerator %NAME Summary of this class goes here % Detailed explanation goes here properties(Access=public) form length fs fsig end methods (Access=public) function obj = Signalgenerator(options) %NAME Construct an instance of this class % Detailed explanation goes here arguments options.form signalform = signalform.sine options.length double = 1024 options.fs double = 1000 %Hz sampling options.fsig double = 50 % Hz fundamental frex e.g. of the sine or sawtooth end % fn = fieldnames(options); for n = 1:numel(fn) try obj.(fn{n}) = options.(fn{n}); end end end function signalclass_out = process(obj) % actual processing of the signal (steps 1. - 3.) signal = obj.build_signal(); signalclass_out = Informationsignal(signal,"fs",obj.fs); % append to logbook lbdesc = ['Signalgenerator: ',char(obj.form), '']; signalclass_out = signalclass_out.logbookentry(lbdesc); end function signal = build_signal(obj) %METHOD1 Summary of this method goes here % Detailed explanation goes here arguments(Input) obj end arguments(Output) signal double end switch obj.form case signalform.sine % Parameters T = 1/obj.fs; % Sampling period (seconds per sample) L = obj.length; % Length of signal (number of samples) t = (0:L-1)*T; % Time vector % Sine wave parameters f = obj.fsig; % Frequency of the sine wave (Hz) A = 1; % Amplitude of the sine wave % Generate sine wave signal = A * sin(2*pi*f*t); case signalform.noise end end end methods (Access=private) % Cant be seen from outside! So put all your functions here that can/ % shall not be called from outside end end