How to give more than one vector as input to polyfit() function?

10 views (last 30 days)
I have a 27x3 matrix of three input variables and one corresponding vector(27x1) as output. I want a polynomial regression equation relating the inputs and the output. The polyfit function gives the following error when given the command: polyfit(input, output, 3)
Error using polyfit (line 48) X and Y vectors must be the same size.
I am new to matlab and so please bear with the noob question. If I am using the wrong function, please let me know the correct procedure for the same.
Thanks in advance,
  2 Comments
Jan
Jan on 6 Jun 2015
And what is the relation between the 3 input vectors and the wanted output? Did you read the docs of polyfit? The first input is the vector of X-values and the second the vector of Y-values. So I cannot imagine what you mean by "input" and "output".
Akash
Akash on 7 Jun 2015
Edited: Akash on 7 Jun 2015
Hello Mr Jan Simon,
Actually I have three values for X, i.e. X1, X2, X3, and the polyfit function takes only one vector as input. I want a relation between X1, X2, X3 and Y, so I combined X1, X2, and X3 into a matrix (input) with the variables as the columns and used this matrix as a single input value to the function polyfit. At this point the previously mentioned error appears. Thanks for answering

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 6 Jun 2015
The polyfitn function from the File Exchange may do what you want.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!