MATLAB: Subscripted assignment dimension mismatch in the “SampEnMLAUC(i_files)= cumtrapz(sampEn_ML);” line

cumtrapzdimension mismatch

In the following code, I am getting a "Subscripted assignment dimension mismatch" in the SampEnMLAUC(i_files)= cumtrapz(sampEn_ML); line. When I used the trapz function on the same line previously, I did not get an error. however, when I used the cumtrapz function, I get the error. what am I missing in the function?
Thank you
N=length(copX);
for t= 2:20
S=t; %S is scale factor
j= fix(N/S);
for i=1:j
copXscale(i)= mean(copX((i-1)*S+1:i*S));
copYscale(i)= mean(copY((i-1)*S+1:i*S));
end
dim = 2;
r = 0.4;
RotatecopX=rot90(copXscale);
RotatecopY=rot90(copYscale);
sampEn_ML(t)=SampEn(dim,r,RotatecopX);
sampEn_AP(t)=SampEn(dim,r,RotatecopY);
end
SampEnMLAUC(i_files)= cumtrapz(sampEn_ML);
SampEnAPAUC(i_files)= cumtrapz(sampEn_AP);

Best Answer

Since it is not possible to determine from the code you posted whether the result of your cumtrapz calls are row or column vectors, it is easiest to save them as cell arrays instead.
Try this:
SampEnMLAUC{i_files} = cumtrapz(sampEn_ML);
SampEnAPAUC{i_files} = cumtrapz(sampEn_AP);
Note the curly braces ‘{}’ denoting cell array indexing.