function [ref] = generateYZScanTrajectory(args) % generateYZScanTrajectory - % % Syntax: [ref] = generateYZScanTrajectory(args) % % Inputs: % - args % % Outputs: % - ref - Reference Signal arguments args.y_tot (1,1) double {mustBeNumeric} = 10e-6 % [m] args.z_tot (1,1) double {mustBeNumeric} = 10e-6 % [m] args.n (1,1) double {mustBeInteger, mustBePositive} = 10 % [-] args.Ts (1,1) double {mustBeNumeric, mustBePositive} = 1e-4 % [s] args.ti (1,1) double {mustBeNumeric, mustBePositive} = 1 % [s] args.tw (1,1) double {mustBeNumeric, mustBePositive} = 1 % [s] args.ty (1,1) double {mustBeNumeric, mustBePositive} = 1 % [s] args.tz (1,1) double {mustBeNumeric, mustBePositive} = 1 % [s] end time_i = 0:args.Ts:args.ti; time_w = 0:args.Ts:args.tw; time_y = 0:args.Ts:args.ty; time_z = 0:args.Ts:args.tz; % Go to initial position y = (time_i/args.ti)*(args.y_tot/2); % Wait y = [y, y(end)*ones(size(time_w))]; % Scans for i = 1:args.n if mod(i,2) == 0 y = [y, -(args.y_tot/2) + (time_y/args.ty)*args.y_tot]; else y = [y, (args.y_tot/2) - (time_y/args.ty)*args.y_tot]; end if i < args.n y = [y, y(end)*ones(size(time_z))]; end end % Wait a litle bit y = [y, y(end)*ones(size(time_w))]; % End motion y = [y, y(end) - y(end)*time_i/args.ti]; % Go to initial position z = (time_i/args.ti)*(args.z_tot/2); % Wait z = [z, z(end)*ones(size(time_w))]; % Scans for i = 1:args.n z = [z, z(end)*ones(size(time_y))]; if i < args.n z = [z, z(end) - (time_z/args.tz)*args.z_tot/(args.n-1)]; end end % Wait a litle bit z = [z, z(end)*ones(size(time_w))]; % End motion z = [z, z(end) - z(end)*time_i/args.ti]; t = 0:args.Ts:args.Ts*(length(y) - 1); ref = zeros(length(y), 7); ref(:, 1) = t; ref(:, 3) = y; ref(:, 4) = z;