【问题标题】:Build a linear plane, approximating the input points建立一个线性平面,逼近输入点
【发布时间】:2016-07-21 12:36:25
【问题描述】:

有必要根据两个标准(特征)构建线性回归图形。我找到了空间直线方程的系数值,但不知道如何使用它们构建平面。我尝试使用“绘图”功能,但这是矩阵大小(维度)的问题。

data = load('mydata.txt');
X1 = data(:, 1); X2 = data(:, 2); Y = X+2.*Y;

theta0 = 0;
theta1 = 0;
theta2 = 0;

%some calculations for all of theta....

x = min(X1):0.1:max(X1);
y = min(X2):0.1:max(X2);
z = theta0 + theta1*x + theta2*y;

plot(x,y,z);

【问题讨论】:

  • 您想使用 3d 绘图工具,例如 mplot3d

标签: matlab plot surface


【解决方案1】:

我找到了解决办法:

[x, y] = meshgrid(min(X):0.1:max(X), min(Y):0.1:max(Y));
z = curT0 + curT1*x + curT2*y;
mesh(x,y,z);     %surface
hold all;
scatter3(X,Y,Z); %points
hold off;

感谢所有考虑过我的问题的人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-22
    • 1970-01-01
    • 1970-01-01
    • 2021-07-11
    • 2012-02-02
    • 1970-01-01
    • 2020-10-20
    相关资源
    最近更新 更多