Programmatic polynomial fitting with mutliple measurements and known parameters

10 views (last 30 days)
I am not new to Matlab, but very new to polynomial modelling of data. I have a set of measurements for observed solubility with specific parameters being changed. There are four parameters that can be experimentally varied.
I have made measurements with 7 different possible values for 3 of the 4 parameters and 10 possible values for the remaining 1 parameter. Therefore my response variable data is a matrix of 70 values (7x10). corresponding to the 10 values for parameter x4 with different values for parameters x1,x2,x3.
Here is what the data looks like:
x1: 1.92683450920000 1.82794091830000 2.01642468230000 1.75600069780000 1.75466924060000 1.83419721490000 1.84217366130000
x2: 275 160 26 76 30 133 107
x3: 0 22 42 40 67 80 100
x4: 100 90 80 70 60 50 40 30 20 10
The responses (7x10) correspond to an experimental condition where the row index is the value from x1,x2,x3,and the column index is the value of x4 used. For practical reasons exhaustive parameter isolation is not possible.
Seems like a simple regression problem, but I can't quite get matlab and polyfit, also tried the polyfitn function to stop complaining about the asymmetry of x variables.
The objective is to determine if (and which) polynomial model best fits the data and describes the reaction.
Any help would be greatly appreciated.
--m
  3 Comments
Martin
Martin on 20 Jun 2012
Hey, sorry for the slow reply.
The 7x10 matrix is a series of solubility measurements for the parameters mentioned above. I have made a csv file that hopefully better explains:
https://dl.dropbox.com/u/24373111/example.csv
thanks
--m
Martin
Martin on 22 Jun 2012
Ah. found it! Thank you very much on your help with this. The functionality of MATLAB never ceases to amaze.
--m

Sign in to comment.

Accepted Answer

Teja Muppirala
Teja Muppirala on 20 Jun 2012
If I understand this correctly, you want model something as y = f(x1,x2,x3,x4), where f is a polynomial of some sort.
You have 70 data points, and if we call your 7x10 response matrix y, then it is arranged like this:
f(1.92, 275, 0, 100) -> y(1,1)
f(1.92, 275, 0, 90) -> y(1,2)
f(1.92, 275, 0, 80) -> y(1,3)
.
.
f(1.82, 160, 22, 100] -> y(2,1)
f(1.82, 160, 22, 90] -> y(2,2)
f(1.82, 160, 22, 80] -> y(2,3)
.
.
f(1.84, 107, 100, 10) -> y(7,10)
In that case, the first step is to put your x's into a 70x4 matrix like this.
x1=[ 1.92683450920000 1.82794091830000 2.01642468230000 1.75600069780000 1.75466924060000 1.83419721490000 1.84217366130000];
x2=[275 160 26 76 30 133 107];
x3=[ 0 22 42 40 67 80 100];
x4=[ 100 90 80 70 60 50 40 30 20 10];
X = [];
for n = 1:7;
X = [X; repmat([x1(n) x2(n) x3(n)],10,1)];
end;
X(:,4) = repmat(x4',7,1);
Now X is a 70x4 matrix representing your inputs.
Next turn your 7x10 matrix y into a 70x1 column vector representing your results.
Y = y(:);
Now there are many ways to fit depending of what form of f you want to use. If you have the latest release of MATLAB along with the Statistics Toolbox installed, a simple first order linear model could be solved like this:
LinearModel.fit(X,Y)
This yields a model of the form y = A*x1 + B*x2 + C*x3 + D*x4 + E
For higher order polynomials, see the help for LinearModel.fit.
  1 Comment
Martin
Martin on 22 Jun 2012
Thanks, I see what I was doing wrong.
Simply the replication of my experimental parameters similar to making a design matrix.
When I have new experimental data I may want to fit a polynomial model. Is there an equally elegant method for this? I dont find a PolynomialModel class similar to LinearModel.
--m

Sign in to comment.

More Answers (1)

John D'Errico
John D'Errico on 20 Jun 2012
You have very little information here in terms of combinations of x1, x2, x3. Essentially you will be able to estimate no more than a linear model in those parameters. Do not try to go higher than that, although you do have sufficient information to try something more complex in x4.

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!