how to plot the data for linear model with 3 variables in matlab?
问题 To plot the data in 3D plane for this model: y = a + a1*x1 + a2*x2 I do like this, the figure is shown in this website (http://kr.mathworks.com/help/stats/regress.html) , x1, x2, and y denote respectively vectors X, Y, and Z. scatter3(x1,x2,y,'filled') hold on x1fit = min(x1):100:max(x1); x2fit = min(x2):10:max(x2); [X1FIT,X2FIT] = meshgrid(x1fit,x2fit); YFIT = b(1) + b(2)*X1FIT + b(3)*X2FIT + b(4)*X1FIT.*X2FIT; mesh(X1FIT,X2FIT,YFIT) xlabel('Weight') ylabel('Horsepower') zlabel('MPG') view