52 lines
1.7 KiB
Matlab
52 lines
1.7 KiB
Matlab
function [sample] = initializeSample(args)
|
|
|
|
arguments
|
|
args.type char {mustBeMember(args.type,{'rigid', 'flexible', 'none', 'init'})} = 'flexible'
|
|
args.radius (1,1) double {mustBeNumeric, mustBePositive} = 0.1 % [m]
|
|
args.height (1,1) double {mustBeNumeric, mustBePositive} = 0.3 % [m]
|
|
args.mass (1,1) double {mustBeNumeric, mustBePositive} = 50 % [kg]
|
|
args.freq (6,1) double {mustBeNumeric, mustBePositive} = 100*ones(6,1) % [Hz]
|
|
args.offset (1,1) double {mustBeNumeric} = 0 % [m]
|
|
args.Foffset logical {mustBeNumericOrLogical} = false
|
|
end
|
|
|
|
sample = struct();
|
|
|
|
switch args.type
|
|
case 'none'
|
|
sample.type = 0;
|
|
case 'rigid'
|
|
sample.type = 1;
|
|
case 'flexible'
|
|
sample.type = 2;
|
|
case 'init'
|
|
sample.type = 3;
|
|
end
|
|
|
|
sample.radius = args.radius; % [m]
|
|
sample.height = args.height; % [m]
|
|
sample.mass = args.mass; % [kg]
|
|
sample.offset = args.offset; % [m]
|
|
|
|
sample.inertia = [1/12 * sample.mass * (3*sample.radius^2 + sample.height^2); ...
|
|
1/12 * sample.mass * (3*sample.radius^2 + sample.height^2); ...
|
|
1/2 * sample.mass * sample.radius^2];
|
|
|
|
sample.K = zeros(6, 1);
|
|
sample.C = zeros(6, 1);
|
|
|
|
sample.K(1:3) = sample.mass .* (2*pi * args.freq(1:3)).^2; % [N/m]
|
|
sample.C(1:3) = 0.1 * sqrt(sample.K(1:3)*sample.mass); % [N/(m/s)]
|
|
|
|
sample.K(4:6) = sample.inertia .* (2*pi * args.freq(4:6)).^2; % [N/m]
|
|
sample.C(4:6) = 0.1 * sqrt(sample.K(4:6).*sample.inertia); % [N/(m/s)]
|
|
|
|
if args.Foffset && ~strcmp(args.type, 'none') && ~strcmp(args.type, 'rigid') && ~strcmp(args.type, 'init')
|
|
load('mat/Foffset.mat', 'Fsm');
|
|
sample.Deq = -Fsm'./sample.K;
|
|
else
|
|
sample.Deq = zeros(6,1);
|
|
end
|
|
|
|
save('./mat/stages.mat', 'sample', '-append');
|