필터 지우기
필터 지우기

how to generate function?

조회 수: 3 (최근 30일)
Shashank Thakker
Shashank Thakker 2014년 8월 8일
댓글: Yu Jiang 2014년 8월 11일
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
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
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.
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
Shashank Thakker
Shashank Thakker 2014년 8월 11일
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 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 CenterFile Exchange에서 Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by