4D plot?

2 ビュー (過去 30 日間)
Rose
Rose 2020 年 8 月 21 日
編集済み: Walter Roberson 2020 年 8 月 21 日
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?

回答 (1 件)

Walter Roberson
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.

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by