Combine data into a singular array using a for loop.

7 vues (au cours des 30 derniers jours)
Sean Leonard
Sean Leonard le 11 Juil 2019
Commenté : Sean Leonard le 11 Juil 2019
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!

Réponses (1)

Sean Leonard
Sean Leonard le 11 Juil 2019
I figured out how to combine it into a cell array with
MyCell(ii)={L_ho} however I am struggling then to export this new cell array to excel on the same sheet for all 60 trials.
  1 commentaire
Sean Leonard
Sean Leonard le 11 Juil 2019
Attempted to add another for-loop to extract the array from each cell and put them in individual cells, as follows.
theArray = MyCell{ii}; % Extract nth cell.
ca=cell(1001,ii*2);
for row=1:size(theArray,1)
ca(row,ii*2-1)=theArray(row,ii); % starts every 2nd column starting from 1 i.e 1,3,5,7 etc
end
end
However this brings an error
Conversion to cell from double is not possible.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by