How can I plot a 3-D mesh using the colorbar as the 4th dimension?
조회 수: 4 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!