Matrix regression- how to make?

1 view (last 30 days)
Nata Salt
Nata Salt on 23 Jan 2015
Commented: Matt J on 23 Jan 2015
Hi . I am completely new in Matlab and programming in general. I am trying to find a polynomial which would convert values from my image data to the mean value of this array. right now I have something like that:
A= importdata( '1slide.tif');
% Rewrite the image in matrix
B= im2uint16(A);
% Find the mean value
M=mean2(B);
E= ones (2048,2048,'uint16');
Mat = M *(E);
Poly= polyfit(B,Mat,6);
A= importdata( '1slide.tif');
% Rewrite the image in matrix
B= im2double(A);
% Find the mean value
M=mean2(B);
E= ones (2048,2048,'double');
Mat = M *(E);
Poly= polyfit(B,Mat,6)
But I got an error:
Undefined function 'qr' for input arguments of type 'uint16'.Error in polyfit (line 66)[Q,R] = qr(V,0);
Why do I need these QR? What should I use for them?

Answers (1)

Matt J
Matt J on 23 Jan 2015
Edited: Matt J on 23 Jan 2015
The input arguments to polyfit are not supposed to be matrices and they are not supposed to be of integer type. Polyfit will perform a single 1D polynomial fit to a vector of x,y data (singles or doubles) that lie on the polynomial.
To better advise, we'd have to know what you're expecting by passing matrices to polyfit instead of vectors.
  3 Comments
Nata Salt
Nata Salt on 23 Jan 2015
May be a loop? for each matrix raw?
Matt J
Matt J on 23 Jan 2015
which converts one matrix value to another one
I think you'll need to define for us what that means.

Sign in to comment.

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!