4D plot?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi All,
I have been struggeling with how to plot the following, and I'm hoping anyone has any ideas on this.
I have this extreme value problem: F(x,y,z)=x^2+y^2+z^2 subject to g(x,y,z)=x^4+y^4+z^4=1. I would like to get a visual of f(x,y,z), and then project g(x,y,z)=1 on f(x,y,z).
I used the following code
[x,y,z] = meshgrid( linspace( -1, 1, 200 ) );
f = x.^2 +y.^2 +z.^2;
figure(1)
isosurface(x, y, z, f)
hold on
[x,y,z] = meshgrid( linspace( -1, 1, 200 ) );
f = x.^4 +y.^4 +z.^4;
figure(1)
isosurface(x, y, z, f,1)
But I have the feeling that this is not correct, as f(x,y,z) should be a sphere (I thought so at least)...
Any thoughts on how to fix this issue?
댓글 수: 0
답변 (1개)
Walter Roberson
2020년 8월 21일
편집: Walter Roberson
2020년 8월 21일
g tells you that x^4+y^4+z^4 = 1
Therefore z^2 = +/- sqrt(1 - x.^4 - y.^4)
Substitute into x^2 + y^2 + z^2 to get
fg = x.^2 + y.^2 +/- sqrt(1 - x.^4 - y.^4)
This does not need a 3d mesh, only a 2d mesh. You will, however, have to break it into two pieces for the +/-
You cannot plot f directly as it is unbounded. You can plot isosurfaces of it, one at a time; each of which is a sphere.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!