Hello,
I have two cells each 60×23 and each cell consist of columns with different length.
For each cell, I need
1- Get ten values starting from last values,
2- Apply fitlm function on the obtained values
3- Get the Coefficients {2,1} of the fitlm
4- omit the last value in step1, shift one value and get ten elements. Then repeat steps 2and3. (hopefully without for loops as i found it complicated with cells having variable lengths).
5- Goal: obtain a 60×23 cell where each cell has the Coefficients of linear regression for each ten values.
My attempted solution works till step 3 as shown:
Time2sec = lst2val % 60x23 cell
delta2sec = delta.delta % 60x23 celllen0 = cellfun(@length, Time2sec, 'uni',0)len1 = cellfun (@(x) x-9, len0, 'uni',0)%len1 = cellfun (@(x) x-10, len0,'uni',0)
len2 = cellfun (@(x) x+9, len1, 'uni',0)last10frames = cellfun (@(x,y1, y2) x( y1:y2 ), Time2sec, len1, len2 , 'Uni',0)len00 = cellfun(@length, delta2sec, 'uni',0)len11 = cellfun (@(x) x-9, len00,'uni',0)len22 = cellfun (@(x) x+9, len11, 'uni',0)last10frames_2 = cellfun (@(x,y1, y2) x( y1:y2 ), delta2sec, len11, len22 , 'Uni',0)reg0 = cellfun (@fitlm, last10frames, last10frames2, 'uni',0)M_value = cellfun (@(x) x.Coefficients{2,1}, reg0 , 'uni', 0) % omit value, shift with step -1 till first element in each cell and apply linear regression.
I really appreciat the help.
Best Answer