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.

댓글 수: 6

fimplicit3 wants a function handle. Try this:
fimplicit3(@(x1,x2,x3) Beta(1)*x1+Beta(2)*x2+Beta(3)*x3+b(1))
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020년 5월 7일
Again returned nothing.
Tommy
Tommy 2020년 5월 7일
Hmm, are you able to provide all of the code which you are running?
Beta is:
Beta(1)= -294449.131783462
Beta(2)=14.7170998874722
Beta(3)=-0.127560549560172
b(1) is
87293272725.0805
f=@(x1,x2,x3) Beta(1).*x1+Beta(2).*x2+Beta(3).*x3+b(1);
fimplicit3(f)
Tommy
Tommy 2020년 5월 8일
I believe nothing shows because there are no solutions within the default interval [-5 5]. But yes, maybe I incorrectly assumed you were trying to plot solutions to f=0.
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020년 5월 8일
You are right I am plotting solution for f=0. I changed the interval and did not show anything.

댓글을 달려면 로그인하십시오.

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 7일

1 개 추천

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

댓글 수: 4

Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020년 5월 8일
@Ameer Hamza
Thanks for the explanation. It is 3D not 4D.I want to plot f=0.
If you want to solve it for f=0, then your equation is linear, and you can write an expression of x3 in terms of x1 and x2 using a symbolic toolbox and then use it to plot a surface. For example
Beta(1)= -294449.131783462;
Beta(2)=14.7170998874722;
Beta(3)=-0.127560549560172;
b(1) = 87293272725.0805;
syms x1 x2 x3
f = Beta(1).*x1+Beta(2).*x2+Beta(3).*x3+b(1);
x3_sol = solve(f, x3);
x3_sol_f = matlabFunction(x3_sol, 'Vars', {x1 x2});
[X1, X2] = meshgrid(-5:0.2:5);
X3 = x3_sol_f(X1, X2);
surf(X1, X2, X3);
shading interp
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020년 5월 10일
when I use zlime even in the surf case, the plot show nothing.
Ameer Hamza
Ameer Hamza 2020년 5월 10일
I haven't used zlim in my code in the comment. Have you tried running that code?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Tommy
Tommy 2020년 5월 8일

1 개 추천

You can pick any interval. Your plot will only show something if solutions to f=0 lie within the interval. [0, 0, -b1/Beta(3)] is a clear solution. -b1/Beta(3) is on the order of 1e11, so how about this:
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);
fimplicit3(f, [-5 5 -5 5 1e10 1e12])

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by