hi, I would perform a simple linear fit on selected data in a large dataset to obtain the intercept and slope values. The data are of the form:
A = [100123 1 1 2500 50; 100123 1 2 2600 51; 100456 1 1 5000 120; 100456 1 2 5500 135; 100456 2 1 6000 150; 100456 2 2 6500 165];
I've to done different linear fit between the 4th (X-data) and the 5th (Y-data) columns depending on the 1st and 2nd columns (Keys and data series).
[key, ~, index] = unique(A(:, [1 2]), 'stable', 'rows');mean = accumarray(index, A(:, 4), [], @mean); % that works!
fit = accumarray(indices, A(:, [4 5]), [], @poly); %Error using accumarray
Second input VAL must be a vector with one element for each row in SUBS, or a scalar.
Is it possible to perform polyfit using the accumarray and handle function @poly ?
Best Answer