How can I plot a 3-D mesh using the colorbar as the 4th dimension?

조회 수: 3 (최근 30일)
Sarah Farthing
Sarah Farthing 2018년 7월 27일
댓글: KSSV 2018년 7월 28일
I am trying to plot the results of a function with 3 input variables.
I have used meshgrid to form 3, 3-D 10x10x10 matrices.
x = linspace(190,245,10);
y = linspace(140,560,10);
z = linspace(0.5,2,10);
[X, Y, Z] = meshgrid(x,y,z)
I then have a number of functions which generate the result I want to plot, let's call it "K", also a 3-D 10x10x10 matrix.
In my mind, I have the idea of a 3-D area with X, Y and Z as the axes and the result K is represented by the colour bar. I could then slice through this surface at various points of the axis to investigate the results there. I've tried using sliceomatic, https://uk.mathworks.com/matlabcentral/fileexchange/764-sliceomatic, but am receiving the following error:
Error using axes
Value must be a 1x2 vector of numeric type in which the second element is
larger than the first and may be Inf
Error in sliceomaticfigure (line 45)
d.axmain = axes('units','normal','pos',[.2 .2 .6 .6],'box','on',...
Error in sliceomatic (line 200)
d = sliceomaticfigure(d,xmesh,ymesh,zmesh);
Does anyone know how to correct this error or have another suggestion for how I could plot my data? I've already amended the sliceomatic script as detailed in the comments on the file exchange.
Thank you!

답변 (1개)

KSSV
KSSV 2018년 7월 27일
x = linspace(190,245,10);
y = linspace(140,560,10);
z = linspace(0.5,2,10);
[X, Y, Z] = meshgrid(x,y,z) ;
figure
hold on
for i = 1:10
surf(X(:,:,i),Y(:,:,i),Z(:,:,i),Z(:,:,i))
end
colorbar
  댓글 수: 2
Sarah Farthing
Sarah Farthing 2018년 7월 27일
편집: Sarah Farthing 2018년 7월 27일
Thanks for the suggestion, it doesn't give the flexibility I'm going for and I don't think I can define these "slices" as easily.
KSSV
KSSV 2018년 7월 28일
What you want more?

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by