how to generate function?

1 Ansicht (letzte 30 Tage)
Shashank Thakker
Shashank Thakker am 8 Aug. 2014
Kommentiert: Yu Jiang am 11 Aug. 2014
I want to generate function to define relationship between reaction rate and mole fraction of species. I've four species. CO,CO2,H2,H2O. So how can i do that by using matlab. If I change value of H2O molefraction with other values as constant it shows that reaction rate increases with increase in h2o mole fraction lke straight line. With co, first it increase and than it decreases with co mole fraction like parabola. Here i'm sharing you some of my results as attachment. Can you guide me how CAN I generate function by using matlab? Can regression method be used? Which linear or non linear? Kindly guide me to solve my query. I would be grateful.
Thank you Shashank Thakker
  1 Kommentar
dpb
dpb am 8 Aug. 2014
...If I change value of H2O molefraction with other values as constant it shows that reaction rate increases with increase in h2o mole fraction lke straight line. With co, first it increase and than it decreases with co mole fraction like parabola...
If you don't have a functional relationship, how did you do the above variations?
Not totally clear on what it is you're after; if the idea is to have a multivariate model that predicts some response to the various input levels possibly a response surface model could be generated.
Regression can fit a particular model to a "one-at-a-time" set of data, yes, but it'll take some other tests/logic to decide what order might be appropriate (or whether some other functional form entirely, perhaps, is called for).
The Statistics Toolbox includes the functions stepwisefit and the interactive tool stepwise that help with such a process with care...

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Yu Jiang
Yu Jiang am 8 Aug. 2014
Bearbeitet: Yu Jiang am 9 Aug. 2014
Hi Shashank
I have just replied your original question
and I am reposting it here for your convenience.
I understand that you would like to perform regression on your data set using MATLAB. In particular, you would like to obtain a function in the following form
Rate = F(CO, CO2, H2, H2O)
where it is not clear what is the best type of functions that should be used here.
I suggest you first try linear regression by using the function regress (Documentation) .
A linear model for this problem looks like
Rate = b(1) * CO + b(2) * CO2 + b(3) *H2 + b(4) *H2O +b(5)
where b is a constant vector of 5 elements. To fit this model in MATLAB, you may try the following steps:
1) Create a matrix X, which is an n-by-5 matrix. The first 4 columns contain the observation from the four species. The fifth column is a column of ones. 2) Create an n-by-1 matrix y, which contains the rate from n different observations.
3) In the MATLAB Command window, try executing the following
>> [b,bint,r] = regress(y,X)
Then, b is the vector of coefficients for the linear model. bint returns the related confidence interval, and r gives the residuals based on which you can see if the fitting is acceptable. To see the difference between the actual data and the data generated by the model, you can simply try
>> n = length(y)
>> plot(1:n, y, o,1:n, X*b )
In which ‘o’ denotes the actual data, and X*b gives you the predicted results. If you would like to perform nonlinear regression, you may want to use the function fitnlm (Documentation) . However, it is necessary that you know the nonlinear structure of the function and can parameterize it with a vector b. I would like to suggest you read related literature and see if some particular structure of nonlinear functions has been used by other people.
-Yu
  2 Kommentare
Shashank Thakker
Shashank Thakker am 11 Aug. 2014
what do you mean by column of ones? you have mentioned that in x matrix i've to take n by 5 matrix in which 4 are readings of species and 5th one is column of ones.
Yu Jiang
Yu Jiang am 11 Aug. 2014
By "column of ones", I mean it is a column with n elements, and all the elements are equal to one. For example, if n=8, then
x(:,5) = [1;
1;
1;
1;
1;
1;
1;
1 ];
This is because the linear model is defined as
Rate = b(1) * CO + b(2) * CO2 + b(3) *H2 + b(4) *H2O +b(5)
which amounts to
Rate = [CO CO2 H2 H2O 1]*b
-Yu

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by