How can I find the relationship (equation) between three independent variables and one dependent variable?
4 views (last 30 days)
Show older comments
Hello.
I am having a hard time finding the relationship between three independent variables and one dependent variable. I know that there exists a relationship between the four, as I took the data from a published article. However, the equation written in the article was in terms of one variable, and I need it written in terms of one of another variable.
The variables (if this helps) are temperature (T), density (rho), salinity (S), and pressure (pressure). For this problem, rho=rho(T,S,pressure). I know with the curvefitting toolbox that you can have two independent variables and one dependent variable, but this doesn't really help me out.
Does anyone have any suggestions? Thanks.
-Ashley
0 Comments
Answers (1)
Star Strider
on 31 Aug 2012
Edited: Star Strider
on 31 Aug 2012
It seems yours may be a multiple linear regression problem. First, all your variables have to be column vectors. Then:
rho = [T S P] * B
where B is your parameter vector. To calculate B from your data, I suggest:
TSP = [ones(size(T)) T S P];
B = TSP\rho
You can also use regress. It has the advantage of providing statistics on the parameters and the fit. The additional ones column fits a constant, and is usually required for an appropriate fit. The constant is equivalent to the y-intercept in the standard linear equation y=m*x+b.
If it is a nonlinear regression problem, lsqcurvefit and nlinfit can both take matrix independent variables and will fit a vector or matrix of dependent variables. That is controlled by your objective function, so as long as it works with the calling routines, you shouldn't have a problem.
0 Comments
See Also
Categories
Find more on Linear and Nonlinear Regression 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!