How to I plot 3D level surfaces of this 4D function?
Afficher commentaires plus anciens
I have the following function. I wish to plot the 3D surface of the function when density equals 100000, 80000, 60000, 40000. I am unsure how to plot a function of 3 variables. Thanks
density= @(x,y,z)10.^5 -24000.*z + 10.^4.*sech((0.75.*x-1.5).^2+(y-1).^2)
Réponses (1)
Walter Roberson
le 13 Nov 2019
Use ndgrid or meshgrid to create a 3D grid of x, y, z locations, and evaluate the function at those points . Suppose we call the result D .
Now use
arrayfun(@(LEVEL) isosurface(x, y, z, D, LEVEL), [100000, 80000, 60000, 40000]);
It is not possible to pass multiple levels to isosurface() in one call.
4 commentaires
Jessica Peterson
le 13 Nov 2019
Walter Roberson
le 13 Nov 2019
density= @(x,y,z)10.^5 -24000.*z + 10.^4.*sech((0.75.*x-1.5).^2+(y-1).^2)
minx = -1; maxx = 5;
miny = -1; maxy = 5;
minz = -1; maxz = 5;
N = 50;
xv = linspace(minx, maxx, N);
yv = linspace(miny, maxy, N);
zv = linspace(minz, maxz, N);
[X, Y, Z] = meshgrid(xv, yv, zv);
D = density(X, Y, Z);
cla
arrayfun(@(LEVEL) isosurface(X, Y, Z, D, LEVEL), [100000, 80000, 60000, 40000]);
xlabel('x');
ylabel('y');
zlabel('z');
legend({'100000', '80000', '60000', '40000'})
Jessica Peterson
le 13 Nov 2019
Walter Roberson
le 13 Nov 2019
Grab the plot with your cursor and rotate it. Or give the command
view(3)
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!