plot 3D fun in x, y and z
4 ビュー (過去 30 日間)
古いコメントを表示
i want to draw a function f varied in x, y and z such that f = xyz using matlab 2014a
0 件のコメント
回答 (2 件)
John BG
2017 年 3 月 28 日
Hi hend
since your function takes in all 3 coordinates, the only way to 'see' or plot the function is slicing the volume comprised by the domain used.
For such purpose the command slice comes really handy, have a look:
N=10
range=[-N:1:N]
[x,y,z] = meshgrid(range,range,range);
v = x.*y.*z;
figure
colormap hsv
for k = range
hsp = surf(linspace(-N,N,numel(range)),linspace(-N,N,numel(range)), zeros(numel(range)) + k);
rotate(hsp,[2,-2,2],15)
xd = hsp.XData;yd = hsp.YData;zd = hsp.ZData;
delete(hsp)
slice(x,y,z,v,[-N,N],2*N,-2*N) % static volume boundaries
hold on
h1=slice(x,y,z,v,xd,yd,zd) % this is the slicing plane
hold off
view(-5,10)
axis([-10 10 -10 10 -10 10])
drawnow
colorbar
end
note the handle h1 to pull the values on the slice plane, that may be useful to extract the slicing plane points with
Xslice=h1.XData
Yslice=h1.YData
Zslice=h1.ZData
the colour bar is also useful to visualise the actual value of the function.
if you find these lines useful would you please be so kind consider marking my answer as Accepted Answer?
To any other reader, if you find this answer of any help would you please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG
0 件のコメント
KSSV
2017 年 3 月 28 日
N = 10 ;
x = linspace(0,1,N) ;
y = linspace(0,1,N) ;
z = linspace(0,1,N) ;
[X,Y,Z] = meshgrid(x,y,z) ;
f = X.*Y.*Z ;
figure(1)
hold on
for i = 1:N
surf(X(:,:,i),Y(:,:,i),Z(:,:,i),f(:,:,i))
end
3 件のコメント
KSSV
2017 年 3 月 28 日
You check the ranges of x, y, z for the given function that's the shape. What you expect? Any image available? Attach it.
KSSV
2017 年 3 月 30 日
N = 10 ;
x = linspace(0,1,N) ;
y = linspace(0,1,N) ;
z = linspace(0,1,N) ;
[X,Y,Z] = meshgrid(x,y,z) ;
F = X.*Y.*Z ;
isosurface(X,Y,Z,F,0)
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!