3 independent variable regression.

29 次查看(过去 30 天)
I'm trying to fit a function with 3 independent variables and 1 dependent. I have all of the data and I've tried a few methods but nothing works.
I want a function set up so that the result would be F where F = f(x,y,z). Developing a model from a matrix of [ x, y, z, F] values. Any suggestions?
To clarify, I don't need to plot it (yet if ever).
  3 个评论
Karen Hejazi
Karen Hejazi 2021-7-11
Hey,
i have the same problem too.I'm trying to fit a function with 3 independent variables and 1 dependent. I have all of the data. i mean the values of all 3 independent variables and 1 dependent are known
but i dont undrestand the solution you have written.
i mean where is F?
i hope you check it. i really appreciate it
Karen Hejazi
Karen Hejazi 2021-7-11
% Q, H and Theta are the three independent variables
Q = [0.5;0.6;0.8;0.9;0.99;1;1;1;1.2;1.2;1.2;1.2;1.5;1.5;1.6;1.8;2;2.3;2.5;2.5;2.8;3.2;3.5;4.5;5.5;6;6;7.1;8];
H = [5;5.3;1.35;2.1;1.05;3.16;3;5;3.57;1.75;3.2;1;3;3.17;1.1;3.45;1.8;2.55;2.55;1.8;2.1;3.6;4.05;1.5;5;5.8;2.97;1.7;1.73];
Theta = [28.5;31.2;25;21.6;20.3;25.2;30;28.9;21.8;22.8;28.7;18.8;20.2;22;20.6;21.5;21.9;22.8;20.4;21.1;19.2;26.4;24.5;17.2;22.9;22.3;25.8;22;19.2];
% Eff is the dependent variable
Eff = [64.8;60.9;70.8;75;71.6;67.7;71.4;67.3;69;67.5;71.5;68;74.8;70.7;73;75.5;73.6;76.5;73.2;70.2;74.5;70.8;70.5;72.6;71.2;73.2;74.4;70.9;72.9];
i want a function for Eff(Q,H,Theta)

请先登录,再进行评论。

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-9-10
There are several ways to solve such problems in MATLAB. If you have the curve fitting toolbox, then you can use fit(): https://www.mathworks.com/help/releases/R2020a/curvefit/fit.html
Alternatively, you can also use functions from optimization toolbox
  3 个评论
Ameer Hamza
Ameer Hamza 2020-9-10
See this example using lsqcurvefit() for 3 independent variables
x = rand(10, 1);
y = rand(10, 1);
z = rand(10, 1);
F = 2*x+5*log(x+z)-3*sin(y); % example
fun = @(p,X) p(1)*X(:,1) + p(2)*log(X(:,1)+X(:,3)) - p(3)*sin(X(:,2));
X = [x y z];
sol = lsqcurvefit(fun, rand(1,3), X, F);
Julia Hoskins
Julia Hoskins 2020-9-11
Yeah, but my F values are an equally sized array and not a function, so the fitting doesn't work.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by