how to generate function?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
dpb
2014 年 8 月 8 日
...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...
採用された回答
Yu Jiang
2014 年 8 月 8 日
編集済み: Yu Jiang
2014 年 8 月 9 日
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.
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 件のコメント
Yu Jiang
2014 年 8 月 11 日
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
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!