Combine data into a singular array using a for loop.
Show older comments
Hi,
I am attempting to find the time at which a coordinate marker is >0 using a for-loop for 60 iterations of a walking trial.
I think the issue is not too complex but I am unsure how to tackle it.
[FName,PName,Filterindex] = uigetfile('*.csv*','MultiSelect','on');
numfiles = size(FName,2);
hz=250;
for ii = 1:numfiles
FName{ii}
entirefile=fullfile(PName,FName{ii})
a=importdata(entirefile);
time=a(:,1)/hz;
data=a(:,3:end);
for n=3:size(data,2)
[f,p,ps(:,n)]=SL_pwr(a(:,3:n),hz);
maxps=max(floor(ps));
end
Fd=Filt(a(:,3:end),hz,2,maxps,'low');
t=linspace(time(1),time(end),1001)';
FdNorm=interp1(time,Fd,t,'spline');
Ltemp1=FdNorm(:,114);
Ltemp2=FdNorm(:,120);
Rtemp1=FdNorm(:,141);
Rtemp2=FdNorm(:,147);
Lcalc=[t Ltemp1];
Ltoe=[t Ltemp2];
Rcalc=[t Rtemp1];
Rtoe=[t Rtemp2];
LC0d=Lcalc-Lcalc(1,:);
LT0d=Ltoe-Ltoe(1,:);
RC0d=Rcalc-Lcalc(1,:);
RT0d=Rtoe-Ltoe(1,:);
%M(find(M(:,4)>0),:)%
target=min(LC0d);
vi1=find(LC0d(:,2) > 1);
L_ho=LC0d(vi1,:);
Vi2=find(LT0d(:,2) > 0);
L_to=LT0d(Vi2,:);
%%stuck here
end
I am attempting to combine the 60 iterations of the trial into a singular array for the L_ho data set(which has two columns for time and the coordinate data when it is >0). The issue I am having is that because each trial is set at different sizes I cannot combine them - I cannot further time-normalise as I am attempting to find a jump in time to understand kinematic gait events and time-normalising would prevent this.
I have been told about the use of a cell array however I am unsure how to use this, alternatively I have thought about exporting the data into a singular excel document using
xlswrite('L_ho.xlsx',L_ho(ii),sheet1);
but this doesn't call all trials it only calls the final trial in the loop.
Any advice/help is greatly appreciated!
Answers (1)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!