I am lost here.
What exactly do you want to plot?
UZ = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/686343/Speed_constant_22062021.zip')
UZ = 1×5 cell array
{'Speed_constant_22062021/Create_MarkersVectors.m'} {'Speed_constant_22062021/matlab.mat'} {'Speed_constant_22062021/OpenFiles.m'} {'Speed_constant_22062021/Time_and_Plotting.asv'} {'Speed_constant_22062021/Time_and_Plotting.m'}
LD = load(UZ{2})
LD = struct with fields:
Sen_Dyn_10: [1628×7 double]
Sen_Dyn_10_2: [1824×7 double]
Sen_Dyn_10_3: [1924×7 double]
Sen_Dyn_20: [2081×7 double]
Sen_Dyn_20_2: [2553×7 double]
Sen_Dyn_20_3: [2071×7 double]
Sen_Dyn_5: [1511×7 double]
Sen_Dyn_5_2: [1540×7 double]
Sen_Dyn_5_3: [2125×7 double]
Sen_StaREF: [803×7 double]
VicDyn_10: [4350×11 double]
VicDyn_10_2: [4831×11 double]
VicDyn_10_3: [4893×11 double]
VicDyn_20: [5356×11 double]
VicDyn_20_2: [6349×11 double]
VicDyn_20_3: [5116×11 double]
VicDyn_5: [5544×11 double]
VicDyn_5_2: [4516×11 double]
VicDyn_5_3: [5664×11 double]
VicREF: [5887×11 double]
MF = fileread(UZ{1})
MF =
'% This file sets up the markers and the vectors for the anaysis
% Run second
close all
%% Marker Points
%Static Reference Trial
% Marker Positions for static marker
marker_1_Ref = VicREF(5:end,3:5)/1000;
marker_2_Ref = VicREF(5:end,6:8)/1000;
marker_3_Ref = VicREF(5:end,9:11)/1000;
%Trail one
% Marker Positions for static marker at 5 deg
marker_1_D5 = VicDyn_5(5:end,3:5)/1000;
marker_2_D5 = VicDyn_5(5:end,6:8)/1000;
marker_3_D5 = VicDyn_5(5:end,9:11)/1000;
% Marker Positions for static marker at 10 deg
marker_1_D10 = VicDyn_10(5:end,3:5)/1000;
marker_2_D10 = VicDyn_10(5:end,6:8)/1000;
marker_3_D10 = VicDyn_10(5:end,9:11)/1000;
% Marker Positions for static marker at 20 deg
marker_1_D20 = VicDyn_20(:,3:5)/1000;
marker_2_D20 = VicDyn_20(:,6:8)/1000;
marker_3_D20 = VicDyn_20(:,9:11)/1000;
%Trail Two
% Marker Positions for static marker at 5 deg
marker_1_D5_2 = VicDyn_5_2(5:end,3:5)/1000;
marker_2_D5_2 = VicDyn_5_2(5:end,6:8)/1000;
marker_3_D5_2 = VicDyn_5_2(5:end,9:11)/1000;
% Marker Positions for static marker at 10 deg
marker_1_D10_2 = VicDyn_10_2(:,3:5)/1000;
marker_2_D10_2 = VicDyn_10_2(:,6:8)/1000;
marker_3_D10_2 = VicDyn_10_2(:,9:11)/1000;
% Marker Positions for static marker at 20 deg
marker_1_D20_2 = VicDyn_20_2(:,3:5)/1000;
marker_2_D20_2 = VicDyn_20_2(:,6:8)/1000;
marker_3_D20_2 = VicDyn_20_2(:,9:11)/1000;
%Trail Three
% Marker Positions for static marker at 5 deg
marker_1_D5_3 = VicDyn_5_3(:,3:5)/1000;
marker_2_D5_3 = VicDyn_5_3(:,6:8)/1000;
marker_3_D5_3 = VicDyn_5_3(:,9:11)/1000;
% Marker Positions for static marker at 10 deg
marker_1_D10_3 = VicDyn_10_3(5:end,3:5)/1000;
marker_2_D10_3 = VicDyn_10_3(5:end,6:8)/1000;
marker_3_D10_3 = VicDyn_10_3(5:end,9:11)/1000;
% Marker Positions for static marker at 20 deg
marker_1_D20_3 = VicDyn_20_3(:,3:5)/1000;
marker_2_D20_3 = VicDyn_20_3(:,6:8)/1000;
marker_3_D20_3 = VicDyn_20_3(:,9:11)/1000;
%Create Source Vectors
%Trial 1
%REF VECTOR
Refvec_1 = marker_2_Ref - marker_1_Ref;
Refvec_2 = marker_3_Ref - marker_1_Ref;
Refvec_3 = cross(Refvec_1, Refvec_2);
Refvec_4 = cross(-Refvec_1, Refvec_3); %Vector in pendulums swining plane
%DYNAMIC
%Vectors at 5 deg
Dvec_1_5 = marker_2_D5 - marker_1_D5;
Dvec_2_5 = marker_3_D5- marker_1_D5;
Dvec_3_5 = cross(Dvec_1_5, Dvec_2_5);
Dvec_4_5 = cross(-Dvec_1_5, Dvec_3_5); %Vector in pendulums swining plane
%Vectors at 10 deg
Dvec_1_10 = marker_2_D10 - marker_1_D10;
Dvec_2_10 = marker_3_D10- marker_1_D10;
Dvec_3_10 = cross(Dvec_1_10, Dvec_2_10);
Dvec_4_10 = cross(-Dvec_1_10, Dvec_3_10); %Vector in pendulums swining plane
%Vectors at 20 deg
Dvec_1_20 = marker_2_D20 - marker_1_D20;
Dvec_2_20 = marker_3_D20- marker_1_D20;
Dvec_3_20 = cross(Dvec_1_20, Dvec_2_20);
Dvec_4_20 = cross(-Dvec_1_20, Dvec_3_20); %Vector in pendulums swining plane
%Trial 2
%Vectors
%Vectors at 5 deg
Dvec_1_5T2 = marker_2_D5_2 - marker_1_D5_2;
Dvec_2_5T2 = marker_3_D5_2- marker_1_D5_2;
Dvec_3_5T2 = cross(Dvec_1_5T2, Dvec_2_5T2);
Dvec_4_5T2 = cross(-Dvec_1_5T2, Dvec_3_5T2); %Vector in pendulums swining plane
%Vectors at 10 deg
Dvec_1_10T2 = marker_2_D10_2 - marker_1_D10_2;
Dvec_2_10T2 = marker_3_D10_2- marker_1_D10_2;
Dvec_3_10T2 = cross(Dvec_1_10T2, Dvec_2_10T2);
Dvec_4_10T2 = cross(-Dvec_1_10T2, Dvec_3_10T2); %Vector in pendulums swining plane
%Vectors at 20 deg
Dvec_1_20T2 = marker_2_D20_2 - marker_1_D20_2;
Dvec_2_20T2 = marker_3_D20_2- marker_1_D20_2;
Dvec_3_20T2 = cross(Dvec_1_20T2, Dvec_2_20T2);
Dvec_4_20T2 = cross(-Dvec_1_20T2, Dvec_3_20T2); %Vector in pendulums swining plane
%Trial 3
%Vectors at 5 deg
Dvec_1_5T3 = marker_2_D5_3 - marker_1_D5_3;
Dvec_2_5T3 = marker_3_D5_3- marker_1_D5_3;
Dvec_3_5T3 = cross(Dvec_1_5T3, Dvec_2_5T3);
Dvec_4_5T3 = cross(-Dvec_1_5T3, Dvec_3_5T3); %Vector in pendulums swining plane
%Vectors at 10 deg
Dvec_1_10T3 = marker_2_D10_3 - marker_1_D10_3;
Dvec_2_10T3 = marker_3_D10_3- marker_1_D10_3;
Dvec_3_10T3 = cross(Dvec_1_10T3, Dvec_2_10T3);
Dvec_4_10T3 = cross(-Dvec_1_10T3, Dvec_3_10T3); %Vector in pendulums swining plane
%Vectors at 20 deg
Dvec_1_20T3 = marker_2_D20_3 - marker_1_D20_3;
Dvec_2_20T3 = marker_3_D20_3- marker_1_D20_3;
Dvec_3_20T3 = cross(Dvec_1_20T3, Dvec_2_20T3);
Dvec_4_20T3 = cross(-Dvec_1_20T3, Dvec_3_20T3); %Vector in pendulums swining plane
%% Making vectors the same length
%Determine longest vector
Vicmax = max([size(Refvec_4,1) size(Refvec_3,1) size(Refvec_1,1) size(Dvec_4_5,1) size(Dvec_1_5,1) size(Dvec_3_5,1) size(Dvec_4_10,1) size(Dvec_1_10,1) size(Dvec_3_10,1) size(Dvec_4_20,1) size(Dvec_1_20,1) size(Dvec_3_20,1) size(Dvec_4_5T2,1) size(Dvec_4_10T2,1) size(Dvec_4_20T2,1) size(Dvec_4_5T3,1) size(Dvec_4_10T3,1) size(Dvec_4_20T3,1) size(Dvec_1_5T2,1) size(Dvec_1_10T2,1) size(Dvec_1_20T2,1) size(Dvec_1_5T3,1) size(Dvec_1_10T3,1) size(Dvec_1_20T3,1) size(Dvec_3_5T2,1) size(Dvec_3_10T2,1) size(Dvec_3_20T2,1) size(Dvec_3_5T3,1) size(Dvec_3_10T3,1) size(Dvec_3_20T3,1)]);
%Padding with zero to make same length
Zpad = zeros(Vicmax,3);
newREFvec_4= Zpad;
newDvec_4_5= Zpad;
newDvec_4_10= Zpad;
newDvec_4_20= Zpad;
newDvec_4_5T2= Zpad;
newDvec_4_10T2= Zpad;
newDvec_4_20T2= Zpad;
newDvec_4_5T3= Zpad;
newDvec_4_10T3= Zpad;
newDvec_4_20T3= Zpad;
newREFvec_1= Zpad;
newDvec_1_5= Zpad;
newDvec_1_10= Zpad;
newDvec_1_20= Zpad;
newDvec_1_5T2= Zpad;
newDvec_1_10T2= Zpad;
newDvec_1_20T2= Zpad;
newDvec_1_5T3= Zpad;
newDvec_1_10T3= Zpad;
newDvec_1_20T3= Zpad;
newREFvec_3= Zpad;
newDvec_3_5= Zpad;
newDvec_3_10= Zpad;
newDvec_3_20= Zpad;
newDvec_3_5T2= Zpad;
newDvec_3_10T2= Zpad;
newDvec_3_20T2= Zpad;
newDvec_3_5T3= Zpad;
newDvec_3_10T3= Zpad;
newDvec_3_20T3= Zpad;
%Ensuring all sizes are the same
newREFvec_4(1:size(Refvec_4),:)= Refvec_4;
newDvec_4_5(1:size(Dvec_4_5),:)= Dvec_4_5;
newDvec_4_10(1:size(Dvec_4_10),:)= Dvec_4_10;
newDvec_4_20(1:size(Dvec_4_20),:)= Dvec_4_20;
newDvec_4_5T2(1:size(Dvec_4_5T2),:)= Dvec_4_5T2;
newDvec_4_10T2(1:size(Dvec_4_10T2),:)= Dvec_4_10T2;
newDvec_4_20T2(1:size(Dvec_4_20T2),:)= Dvec_4_20T2;
newDvec_4_5T3(1:size(Dvec_4_5T3),:)= Dvec_4_5T3;
newDvec_4_10T3(1:size(Dvec_4_10T3),:)= Dvec_4_10T3;
newDvec_4_20T3(1:size(Dvec_4_20T3),:)= Dvec_4_20T3;
newREFvec_1(1:size(Refvec_1),:)= Refvec_1;
newDvec_1_5(1:size(Dvec_1_5),:)= Dvec_1_5;
newDvec_1_10(1:size(Dvec_1_10),:)= Dvec_1_10;
newDvec_1_20(1:size(Dvec_1_20),:)= Dvec_1_20;
newDvec_1_5T2(1:size(Dvec_1_5T2),:)= Dvec_1_5T2;
newDvec_1_10T2(1:size(Dvec_1_10T2),:)= Dvec_1_10T2;
newDvec_1_20T2(1:size(Dvec_1_20T2),:)= Dvec_1_20T2;
newDvec_1_5T3(1:size(Dvec_1_5T3),:)= Dvec_1_5T3;
newDvec_1_10T3(1:size(Dvec_1_10T3),:)= Dvec_1_10T3;
newDvec_1_20T3(1:size(Dvec_1_20T3),:)= Dvec_1_20T3;
newREFvec_3(1:size(Refvec_3),:)= Refvec_3;
newDvec_3_5(1:size(Dvec_3_5),:)= Dvec_3_5;
newDvec_3_10(1:size(Dvec_3_10),:)= Dvec_3_10;
newDvec_3_20(1:size(Dvec_3_20),:)= Dvec_3_20;
newDvec_3_5T2(1:size(Dvec_3_5T2),:)= Dvec_3_5T2;
newDvec_3_10T2(1:size(Dvec_3_10T2),:)= Dvec_3_10T2;
newDvec_3_20T2(1:size(Dvec_3_20T2),:)= Dvec_3_20T2;
newDvec_3_5T3(1:size(Dvec_3_5T3),:)= Dvec_3_5T3;
newDvec_3_10T3(1:size(Dvec_3_10T3),:)= Dvec_3_10T3;
newDvec_3_20T3(1:size(Dvec_3_20T3),:)= Dvec_3_20T3;
%% Vector Magnitudes for pendulum plane
Mag_newvec_4_Ref = sqrt((newREFvec_4(:,1)).^2 + (newREFvec_4(:,2)).^2 + (newREFvec_4(:,3)).^2);
Mag_newDvec_4_5 = sqrt((newDvec_4_5(:,1)).^2 + (newDvec_4_5(:,2)).^2 + (newDvec_4_5(:,3)).^2);
Mag_newDvec_4_10= sqrt((newDvec_4_10(:,1)).^2 + (newDvec_4_10(:,2)).^2 + (newDvec_4_10(:,3)).^2);
Mag_newDvec_4_20= sqrt((newDvec_4_20(:,1)).^2 + (newDvec_4_20(:,2)).^2 + (newDvec_4_20(:,3)).^2);
Mag_newDvec_4_5T2= sqrt((newDvec_4_5T2(:,1)).^2 + (newDvec_4_5T2(:,2)).^2 + (newDvec_4_5T2(:,3)).^2);
Mag_newDvec_4_10T2= sqrt((newDvec_4_10T2(:,1)).^2 + (newDvec_4_10T2(:,2)).^2 + (newDvec_4_10T2(:,3)).^2);
Mag_newDvec_4_20T2= sqrt((newDvec_4_20T2(:,1)).^2 + (newDvec_4_20T2(:,2)).^2 + (newDvec_4_20T2(:,3)).^2);
Mag_newDvec_4_5T3= sqrt((newDvec_4_5T3(:,1)).^2 + (newDvec_4_5T3(:,2)).^2 + (newDvec_4_5T3(:,3)).^2);
Mag_newDvec_4_10T3= sqrt((newDvec_4_10T3(:,1)).^2 + (newDvec_4_10T3(:,2)).^2 + (newDvec_4_10T3(:,3)).^2);
Mag_newDvec_4_20T3= sqrt((newDvec_4_20T3(:,1)).^2 + (newDvec_4_20T3(:,2)).^2 + (newDvec_4_20T3(:,3)).^2);
Mag_newvec_1_Ref = sqrt((newREFvec_1(:,1)).^2 + (newREFvec_1(:,2)).^2 + (newREFvec_1(:,3)).^2);
Mag_newDvec_1_5 = sqrt((newDvec_1_5(:,1)).^2 + (newDvec_1_5(:,2)).^2 + (newDvec_1_5(:,3)).^2);
Mag_newDvec_1_10= sqrt((newDvec_1_10(:,1)).^2 + (newDvec_1_10(:,2)).^2 + (newDvec_1_10(:,3)).^2);
Mag_newDvec_1_20= sqrt((newDvec_1_20(:,1)).^2 + (newDvec_1_20(:,2)).^2 + (newDvec_1_20(:,3)).^2);
Mag_newDvec_1_5T2= sqrt((newDvec_1_5T2(:,1)).^2 + (newDvec_1_5T2(:,2)).^2 + (newDvec_1_5T2(:,3)).^2);
Mag_newDvec_1_10T2= sqrt((newDvec_1_10T2(:,1)).^2 + (newDvec_1_10T2(:,2)).^2 + (newDvec_1_10T2(:,3)).^2);
Mag_newDvec_1_20T2= sqrt((newDvec_1_20T2(:,1)).^2 + (newDvec_1_20T2(:,2)).^2 + (newDvec_1_20T2(:,3)).^2);
Mag_newDvec_1_5T3= sqrt((newDvec_1_5T3(:,1)).^2 + (newDvec_1_5T3(:,2)).^2 + (newDvec_1_5T3(:,3)).^2);
Mag_newDvec_1_10T3= sqrt((newDvec_1_10T3(:,1)).^2 + (newDvec_1_10T3(:,2)).^2 + (newDvec_1_10T3(:,3)).^2);
Mag_newDvec_1_20T3= sqrt((newDvec_1_20T3(:,1)).^2 + (newDvec_1_20T3(:,2)).^2 + (newDvec_1_20T3(:,3)).^2);
Mag_newvec_3_Ref = sqrt((newREFvec_3(:,1)).^2 + (newREFvec_3(:,2)).^2 + (newREFvec_3(:,3)).^2);
Mag_newDvec_3_5 = sqrt((newDvec_3_5(:,1)).^2 + (newDvec_3_5(:,2)).^2 + (newDvec_3_5(:,3)).^2);
Mag_newDvec_3_10= sqrt((newDvec_3_10(:,1)).^2 + (newDvec_3_10(:,2)).^2 + (newDvec_3_10(:,3)).^2);
Mag_newDvec_3_20= sqrt((newDvec_3_20(:,1)).^2 + (newDvec_3_20(:,2)).^2 + (newDvec_3_20(:,3)).^2);
Mag_newDvec_3_5T2= sqrt((newDvec_3_5T2(:,1)).^2 + (newDvec_3_5T2(:,2)).^2 + (newDvec_3_5T2(:,3)).^2);
Mag_newDvec_3_10T2= sqrt((newDvec_3_10T2(:,1)).^2 + (newDvec_3_10T2(:,2)).^2 + (newDvec_3_10T2(:,3)).^2);
Mag_newDvec_3_20T2= sqrt((newDvec_3_20T2(:,1)).^2 + (newDvec_3_20T2(:,2)).^2 + (newDvec_3_20T2(:,3)).^2);
Mag_newDvec_3_5T3= sqrt((newDvec_3_5T3(:,1)).^2 + (newDvec_3_5T3(:,2)).^2 + (newDvec_3_5T3(:,3)).^2);
Mag_newDvec_3_10T3= sqrt((newDvec_3_10T3(:,1)).^2 + (newDvec_3_10T3(:,2)).^2 + (newDvec_3_10T3(:,3)).^2);
Mag_newDvec_3_20T3= sqrt((newDvec_3_20T3(:,1)).^2 + (newDvec_3_20T3(:,2)).^2 + (newDvec_3_20T3(:,3)).^2);
%% Unit vectors for all trails
iunit_REFvec_3 = newREFvec_3./(Mag_newvec_3_Ref+eps);
iunit_Dvec_3_5 = newDvec_3_5./(Mag_newDvec_3_5+eps);
iunit_Dvec_3_10 = newDvec_3_10./(Mag_newDvec_3_10+eps);
iunit_Dvec_3_20 = newDvec_3_20./(Mag_newDvec_3_20+eps);
iunit_Dvec_3_5T2 = newDvec_3_5T2./(Mag_newDvec_3_5T2+eps);
iunit_Dvec_3_10T2 = newDvec_3_10T2./(Mag_newDvec_3_10T2+eps);
iunit_Dvec_3_20T2 = newDvec_3_20T2./(Mag_newDvec_3_20T2+eps);
iunit_Dvec_3_5T3 = newDvec_3_5T3./(Mag_newDvec_3_5T3+eps);
iunit_Dvec_3_10T3 = newDvec_3_10T3./(Mag_newDvec_3_10T3+eps);
iunit_Dvec_3_20T3 = newDvec_3_20T3./(Mag_newDvec_3_20T3+eps);
junit_REFvec_4 = newREFvec_4./(Mag_newvec_4_Ref+eps);
junit_Dvec_4_5 = newDvec_4_5./(Mag_newDvec_4_5+eps);
junit_Dvec_4_10 = newDvec_4_10./(Mag_newDvec_4_10+eps);
junit_Dvec_4_20 = newDvec_4_20./(Mag_newDvec_4_20+eps);
junit_Dvec_4_5T2 = newDvec_4_5T2./(Mag_newDvec_4_5T2+eps);
junit_Dvec_4_10T2 = newDvec_4_10T2./(Mag_newDvec_4_10T2+eps);
junit_Dvec_4_20T2 = newDvec_4_20T2./(Mag_newDvec_4_20T2+eps);
junit_Dvec_4_5T3 = newDvec_4_5T3./(Mag_newDvec_4_5T3+eps);
junit_Dvec_4_10T3 = newDvec_4_10T3./(Mag_newDvec_4_10T3+eps);
junit_Dvec_4_20T3 = newDvec_4_20T3./(Mag_newDvec_4_20T3+eps);
kunit_REFvec_1 = -newREFvec_1./(Mag_newvec_1_Ref+eps);
kunit_Dvec_1_5 = -newDvec_1_5./(Mag_newDvec_1_5+eps);
kunit_Dvec_1_10 = -newDvec_1_10./(Mag_newDvec_1_10+eps);
kunit_Dvec_1_20 = -newDvec_1_20./(Mag_newDvec_1_20+eps);
kunit_Dvec_1_5T2 = -newDvec_1_5T2./(Mag_newDvec_1_5T2+eps);
kunit_Dvec_1_10T2 = -newDvec_1_10T2./(Mag_newDvec_1_10T2+eps);
kunit_Dvec_1_20T2 = -newDvec_1_20T2./(Mag_newDvec_1_20T2+eps);
kunit_Dvec_1_5T3 = -newDvec_1_5T3./(Mag_newDvec_1_5T3+eps);
kunit_Dvec_1_10T3 = -newDvec_1_10T3./(Mag_newDvec_1_10T3+eps);
kunit_Dvec_1_20T3 = -newDvec_1_20T3./(Mag_newDvec_1_20T3+eps);
%% Setting up Segment coordinate system and calculate angles
%Proximal = Static Ref vector
% 5Def
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p5 = [iunit_Dvec_3_5(ci,:)', junit_Dvec_4_5(ci,:)', kunit_Dvec_1_5(ci,:)']; %First entry
R_5 = p5'.*p1;
sinBeta_5 = R_5(3,1); % ok
Beta_5(ci) = (180.*(asin(sinBeta_5))./pi); % ok
tanalpha_5 = -(R_5(3,2))./(R_5(3,3)); % ok
alpha_5(ci) = (180.*(atan(tanalpha_5))./pi);
tangamma_5 = -(R_5(2,1))./(R_5(1,1));
gamma_5(ci) = (180.*(atan(tangamma_5))./pi);
end
% 20Def
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p20 = [iunit_Dvec_3_20(ci,:)', junit_Dvec_4_20(ci,:)', kunit_Dvec_1_20(ci,:)']; %First entry
R_20 = p20'.*p1;
sinBeta_20 = R_20(3,1); % ok
Beta_20(ci) = (180.*(asin(sinBeta_20))./pi); % ok
tanalpha_20 = -(R_20(3,2))./(R_20(3,3)); % ok
alpha_20(ci) = (180.*(atan(tanalpha_20))./pi);
tangamma_20 = -(R_20(2,1))./(R_20(1,1));
gamma_20(ci) = (180.*(atan(tangamma_20))./pi);
end
% 10Def
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p10 = [iunit_Dvec_3_10(ci,:)', junit_Dvec_4_10(ci,:)', kunit_Dvec_1_10(ci,:)']; %First entry
R_10 = p10'.*p1;
sinBeta_10 = R_10(3,1); % ok
Beta_10(ci) = (180.*(asin(sinBeta_10))./pi); % ok
tanalpha_10 = -(R_10(3,2))./(R_10(3,3)); % ok
alpha_10(ci) = (180.*(atan(tanalpha_10))./pi);
tangamma_10 = -(R_10(2,1))./(R_10(1,1));
gamma_10(ci) = (180.*(atan(tangamma_10))./pi);
end
% 5Deg Trail 2
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p5T2 = [iunit_Dvec_3_5T2(ci,:)', junit_Dvec_4_5T2(ci,:)', kunit_Dvec_1_5T2(ci,:)']; %First entry
R_5T2 = p5T2'.*p1;
sinBeta_5T2 = R_5T2(3,1); % ok
Beta_5T2(ci) = (180.*(asin(sinBeta_5T2))./pi); % ok
tanalpha_5T2 = -(R_5T2(3,2))./(R_5T2(3,3)); % ok
alpha_5T2(ci) = (180.*(atan(tanalpha_5T2))./pi);
tangamma_5T2 = -(R_5T2(2,1))./(R_5T2(1,1));
gamma_5T2(ci) = (180.*(atan(tangamma_5T2))./pi);
end
% 20Def
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p20T2 = [iunit_Dvec_3_20T2(ci,:)', junit_Dvec_4_20T2(ci,:)', kunit_Dvec_1_20T2(ci,:)']; %First entry
R_20T2 = p20T2'.*p1;
sinBeta_20T2 = R_20T2(3,1); % ok
Beta_20T2(ci) = (180.*(asin(sinBeta_20T2))./pi); % ok
tanalpha_20T2 = -(R_20T2(3,2))./(R_20T2(3,3)); % ok
alpha_20T2(ci) = (180.*(atan(tanalpha_20T2))./pi);
tangamma_20T2 = -(R_20T2(2,1))./(R_20T2(1,1));
gamma_20T2(ci) = (180.*(atan(tangamma_20T2))./pi);
end
% 10Def
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p10T2 = [iunit_Dvec_3_10T2(ci,:)', junit_Dvec_4_10T2(ci,:)', kunit_Dvec_1_10T2(ci,:)']; %First entry
R_10T2 = p10T2'.*p1;
sinBeta_10T2 = R_10T2(3,1); % ok
Beta_10T2(ci) = (180.*(asin(sinBeta_10T2))./pi); % ok
tanalpha_10T2 = -(R_10T2(3,2))./(R_10T2(3,3)); % ok
alpha_10T2(ci) = (180.*(atan(tanalpha_10T2))./pi);
tangamma_10T2 = -(R_10T2(2,1))./(R_10T2(1,1));
gamma_10T2(ci) = (180.*(atan(tangamma_10T2))./pi);
end
% 5Deg Trial 3
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p5T3 = [iunit_Dvec_3_5T3(ci,:)', junit_Dvec_4_5T3(ci,:)', kunit_Dvec_1_5T3(ci,:)']; %First entry
R_5T3 = p5T3'.*p1;
sinBeta_5T3 = R_5T3(3,1); % ok
Beta_5T3(ci) = (180.*(asin(sinBeta_5T3))./pi); % ok
tanalpha_5T3 = -(R_5T3(3,2))./(R_5T3(3,3)); % ok
alpha_5T3(ci) = (180.*(atan(tanalpha_5T3))./pi);
tangamma_5T3 = -(R_5T3(2,1))./(R_5T3(1,1));
gamma_5T3(ci) = (180.*(atan(tangamma_5T3))./pi);
end
% 20Deg
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p20T3 = [iunit_Dvec_3_20T3(ci,:)', junit_Dvec_4_20T3(ci,:)', kunit_Dvec_1_20T3(ci,:)']; %First entry
R_20T3 = p20T3'.*p1;
sinBeta_20T3 = R_20T3(3,1); % ok
Beta_20T3(ci) = (180.*(asin(sinBeta_20T3))./pi); % ok
tanalpha_20T3 = -(R_20T3(3,2))./(R_20T3(3,3)); % ok
alpha_20T3(ci) = (180.*(atan(tanalpha_20T3))./pi);
tangamma_20T3 = -(R_20T3(2,1))./(R_20T3(1,1));
gamma_20T3(ci) = (180.*(atan(tangamma_20T3))./pi);
end
% 10Def
for ci = 1:Vicmax
p1 = [iunit_REFvec_3(ci,:)', junit_REFvec_4(ci,:)', kunit_REFvec_1(ci,:)']; %First entry
p10T3 = [iunit_Dvec_3_10T3(ci,:)', junit_Dvec_4_10T3(ci,:)', kunit_Dvec_1_10T3(ci,:)']; %First entry
R_10T3 = p10T3'.*p1;
sinBeta_10T3 = R_10T3(3,1); % ok
Beta_10T3(ci) = (180.*(asin(sinBeta_10T3))./pi); % ok
tanalpha_10T3 = -(R_10T3(3,2))./(R_10T3(3,3)); % ok
alpha_10T3(ci) = (180.*(atan(tanalpha_10T3))./pi);
tangamma_10T3 = -(R_10T3(2,1))./(R_10T3(1,1));
gamma_10T3(ci) = (180.*(atan(tangamma_10T3))./pi);
end
%% Motion Sense Angles
%Open motion sense static file
%First trial
MSSen_StaREF = Sen_StaREF(:,6);
MSSen_Dyn_5 = Sen_Dyn_5(:,6);
MSSen_Dyn_10 = Sen_Dyn_10(:,6);
MSSen_Dyn_20 =Sen_Dyn_20(:,6);
%Second trial
MSSen_Dyn_5_2 = Sen_Dyn_5_2(:,6);
MSSen_Dyn_10_2 = Sen_Dyn_10_2(:,6);
MSSen_Dyn_20_2 = Sen_Dyn_20_2(:,6);
%Third trial
MSSen_Dyn_5_3 = Sen_Dyn_5_3(:,6);
MSSen_Dyn_10_3 = Sen_Dyn_10_3(:,6);
MSSen_Dyn_20_3 = Sen_Dyn_20_3(:,6);
%Determine longest Motionsense vector
MSmax = max([size(MSSen_StaREF,1) size(MSSen_Dyn_5,1) size(MSSen_Dyn_10,1) size(MSSen_Dyn_20,1) size(MSSen_Dyn_5_2,1) size(MSSen_Dyn_10_2,1) size(MSSen_Dyn_20_2,1) size(MSSen_Dyn_5_3,1) size(MSSen_Dyn_10_3,1) size(MSSen_Dyn_20_3,1)]);
%Padding with zero to make same length
MSpad = zeros(MSmax,1);
newMS= MSpad;
newMS_5= MSpad;
newMS_10= MSpad;
newMS_20= MSpad;
newMS_T2= MSpad;
newMS_5T2= MSpad;
newMS_10T2= MSpad;
newMS_20T2= MSpad;
newMS_5T3= MSpad;
newMS_10T3= MSpad;
newMS_20T3= MSpad;
%Ensuring all sizes are the same
newMS(1:size(MSSen_StaREF),:)= MSSen_StaREF;
newMS_5(1:size(MSSen_Dyn_5),:)= MSSen_Dyn_5;
newMS_10(1:size(MSSen_Dyn_10),:)= MSSen_Dyn_10;
newMS_20(1:size(MSSen_Dyn_20),:)= MSSen_Dyn_20;
newMS_5T2(1:size(MSSen_Dyn_5_2),:)= MSSen_Dyn_5_2;
newMS_10T2(1:size(MSSen_Dyn_10_2),:)= MSSen_Dyn_10_2;
newMS_20T2(1:size(MSSen_Dyn_20_2),:)= MSSen_Dyn_20_2;
newMS_5T3(1:size(MSSen_Dyn_5_3),:)= MSSen_Dyn_5_3;
newMS_10T3(1:size(MSSen_Dyn_10_3),:)= MSSen_Dyn_10_3;
newMS_20T3(1:size(MSSen_Dyn_20_3),:)= MSSen_Dyn_20_3;
%% Correcting angle of motionsense due to misalignment of reference angle.
%Reference Vector for motionSense - this the angle read when the pendulum
%is at rest in the vertical position. Should be 0 degrees in this position
RefAngle_T1 = newMS;
%Accounting for misalignment- All angles as if the vertical reference is
%zero degrees.
MS_Alignmnet= newMS - abs(RefAngle_T1);
MS_5_Alignment = newMS_5 + abs(RefAngle_T1);
MS_10_Alignment = newMS_10 + abs(RefAngle_T1);
MS_20_Alignment = newMS_20 + abs(RefAngle_T1);
MS_5_AlignmentT2 = newMS_5T2 + abs(RefAngle_T1);
MS_10_AlignmentT2 = newMS_10T2 + abs(RefAngle_T1);
MS_20_AlignmentT2 = newMS_20T2 + abs(RefAngle_T1);
MS_5_AlignmentT3 = newMS_5T3 + abs(RefAngle_T1);
MS_10_AlignmentT3 = newMS_10T3 + abs(RefAngle_T1);
MS_20_AlignmentT3 = newMS_20T3 + abs(RefAngle_T1);
'
VicREF = LD.VicREF
VicREF = 5887×11
1.0e+03 *
0.1000 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
0.0010 0 0.0245 0.1156 1.1259 0.0296 0.1080 0.4497 0.0311 0.1510 0.4472
0.0020 0 0.0245 0.1156 1.1259 0.0297 0.1080 0.4497 0.0311 0.1510 0.4472
0.0030 0 0.0245 0.1156 1.1259 0.0297 0.1080 0.4497 0.0311 0.1510 0.4472
0.0040 0 0.0245 0.1156 1.1259 0.0297 0.1079 0.4497 0.0311 0.1510 0.4472
0.0050 0 0.0245 0.1156 1.1259 0.0297 0.1079 0.4497 0.0311 0.1510 0.4472
0.0060 0 0.0245 0.1156 1.1258 0.0297 0.1079 0.4497 0.0311 0.1510 0.4471
.