I have a cell array of data. The array is a single column with something between 500 and 3000 elements. Each element consists of a matrix with four columns. The first column are the x-, the second the y-values, whereas the third, and fourth column are irrelevant.
What I would like to do know is to fit these x- and y-values to a linear function (y=a*x+b), but not all the values, only a fraction - e.g. the first 10, 20, or 50%, the rest should not be considered. I have problems to access the relevant data in the cell array properly and to find a way to fit only a fraction of the data. What makes the task for me even more challenging is that the number of x- and y-values is different for every element of the array.
Although the elements of the array all have the size 500x4, some of them only exhibit several x- and y-paris and almost only NaN at the end, some of them almost 500 and only several NaN.