MATLAB: Matlab 3 variable function plot

3dplotfunctionplot

The equation is:
f(X1,X2,X3)=bt1.x1+bt2.X2+bt3.X3+b1
bt1 to bt3 and b1 are all constants.
and I want to plot it in 3D. I tried a couple of functions like:
figure
syms x1 x2 x3
fimplicit3(Beta(1)*x1+Beta(2)*x2+Beta(3)*x3+b(1))
but it retunrs nothing.

Best Answer

fimplicit3 is used to plot implicit equations with three variables. What you have is 4D data (3 input variables, 1 output variable). You need to use a 4D visualization function, like slice(), to visualize your function. See this example
Beta(1)= -294449.131783462;
Beta(2)=14.7170998874722;
Beta(3)=-0.127560549560172;
b(1) = 87293272725.0805;
f=@(x1,x2,x3) Beta(1).*x1+Beta(2).*x2+Beta(3).*x3+b(1);
[X1,X2,X3] = meshgrid(linspace(-1,1));
V = f(X1,X2,X3);
slice(X1, X2, X3, V, [-0.5 0.5], 0.3, 0)
colorbar
shading interp
Related Question