Analyze first measurements
This commit is contained in:
54
matlab/src/generateSinIncreasingAmpl.m
Normal file
54
matlab/src/generateSinIncreasingAmpl.m
Normal file
@@ -0,0 +1,54 @@
|
||||
function [U_exc] = generateSinIncreasingAmpl(args)
|
||||
% generateSinIncreasingAmpl - Generate Sinus with increasing amplitude
|
||||
%
|
||||
% Syntax: [U_exc] = generateSinIncreasingAmpl(args)
|
||||
%
|
||||
% Inputs:
|
||||
% - args - Optinal arguments:
|
||||
% - Ts - Sampling Time - [s]
|
||||
% - V_mean - Mean value of the excitation voltage - [V]
|
||||
% - sin_ampls - Excitation Amplitudes - [V]
|
||||
% - sin_freq - Excitation Frequency - [Hz]
|
||||
% - sin_num - Number of period for each amplitude - [-]
|
||||
% - t_start - Time at which the excitation begins - [s]
|
||||
% - smooth_ends - 'true' or 'false': smooth transition between 0 and V_mean - [-]
|
||||
|
||||
arguments
|
||||
args.Ts (1,1) double {mustBeNumeric, mustBePositive} = 1e-4
|
||||
args.V_mean (1,1) double {mustBeNumeric} = 0
|
||||
args.sin_ampls double {mustBeNumeric, mustBePositive} = [0.1, 0.2, 0.3]
|
||||
args.sin_period (1,1) double {mustBeNumeric, mustBePositive} = 1
|
||||
args.sin_num (1,1) double {mustBeNumeric, mustBePositive, mustBeInteger} = 3
|
||||
args.t_start (1,1) double {mustBeNumeric, mustBePositive} = 5
|
||||
args.smooth_ends logical {mustBeNumericOrLogical} = true
|
||||
end
|
||||
|
||||
t_noise = 0:args.Ts:args.sin_period*args.sin_num;
|
||||
sin_exc = [];
|
||||
|
||||
for sin_ampl = args.sin_ampls
|
||||
sin_exc = [sin_exc, args.V_mean + sin_ampl*sin(2*pi/args.sin_period*t_noise)];
|
||||
end
|
||||
|
||||
t_smooth_start = args.Ts:args.Ts:args.t_start;
|
||||
|
||||
V_smooth_start = zeros(size(t_smooth_start));
|
||||
V_smooth_end = zeros(size(t_smooth_start));
|
||||
|
||||
if args.smooth_ends
|
||||
Vd_max = args.V_mean/(0.7*args.t_start);
|
||||
|
||||
V_d = zeros(size(t_smooth_start));
|
||||
V_d(t_smooth_start < 0.2*args.t_start) = t_smooth_start(t_smooth_start < 0.2*args.t_start)*Vd_max/(0.2*args.t_start);
|
||||
V_d(t_smooth_start > 0.2*args.t_start & t_smooth_start < 0.7*args.t_start) = Vd_max;
|
||||
V_d(t_smooth_start > 0.7*args.t_start & t_smooth_start < 0.9*args.t_start) = Vd_max - (t_smooth_start(t_smooth_start > 0.7*args.t_start & t_smooth_start < 0.9*args.t_start) - 0.7*args.t_start)*Vd_max/(0.2*args.t_start);
|
||||
|
||||
V_smooth_start = cumtrapz(V_d)*args.Ts;
|
||||
|
||||
V_smooth_end = args.V_mean - V_smooth_start;
|
||||
end
|
||||
|
||||
V_exc = [V_smooth_start, sin_exc, V_smooth_end];
|
||||
t_exc = args.Ts*[0:1:length(V_exc)-1];
|
||||
|
||||
U_exc = [t_exc; V_exc];
|
Reference in New Issue
Block a user