Plot a multiple linear regression

5 ビュー (過去 30 日間)
Bao Vo
Bao Vo 2020 年 3 月 14 日
回答済み: Ameer Hamza 2020 年 3 月 15 日
Hi everyone,
I don't know how to plot a multiple linear regression with 3 independent variables. Let say I have a function f(x,y,z) = 3x+4y+z. I would like 3 variables are on 3 axes and the result will be expressed by color scale. Anybody used to plot this kind of function, please help me.
Thanks much

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 3 月 15 日
You can use slice and contourslice to visualize 4D data. For example
[X,Y,Z] = meshgrid(-5:0.1:5);
C = 3*X+4*Y+Z;
figure();
slice(X,Y,Z,C, [-2 0 2], [], [-2 2]);
figure();
contourslice(X,Y,Z,C, -5:1:5, [], []);
view(3);

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by