Hello,
I am solving a problem where I have three vectors (one for each 3D dimension), with different lengths and unevenly spaced, and a temperature matrix where each entry corresponds to the temperature at the position (x(i),y(j),z(k)). My goal is to make a 4D plot where the forth dimension (temperature) is represented my a colour (see attached file).
I have searched for an answer but did not get any solution for the conditions that I presented (3 vectors with 1 matrix). What function or approach would you recommend me to try?
*Data type*
length of x = M
length of y = N
length of z = P
size of Temperature matrix = M x N x P
Thanks in advance.

 채택된 답변

Walter Roberson
Walter Roberson 2015년 6월 20일

1 개 추천

You can create a scattered interpolant and then sample it along grids. But as is hinted in your image, the outside is going to hide the inside when you plot. You can work with a voxel viewing routine or you can create isosurfaces to try to deal with that.

댓글 수: 4

Simao Nobrega
Simao Nobrega 2015년 6월 21일
Hello Walter Roberson,
Thank you for your answer.
After making the interpolation, how it is possible to plot the results? I still have the same problem. Scattered interpolant only allows me to determine the values of the temperature in other points out of my grid.
Thank you
Walter Roberson
Walter Roberson 2015년 6월 21일
Ah, I did not notice before that you have a grid already but that it is just not regularly spaced. I was reading the question as one about the values being completely scattered, in which case gridding would have been necessary for presentation. With an existing but not-evenly spaced grid, I will need to think a little about what will work well.
[X, Y, Z] = ndgrid(x, y, z);
slice(X, Y, Z, temperature, [min(x), max(x)], [min(y), max(y)], [min(z), max(z)], 'cubic')
Simao Nobrega
Simao Nobrega 2015년 6월 21일
Thank you Walter for your answer.
Worked like charm! Slice is a very nice function.
Best regards

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

추가 답변 (1개)

Hugo
Hugo 2015년 6월 20일

0 개 추천

You could use "patch" since the surface will hide the interior points. You can create a matrix containing the coordinates of each point on the surface and then another matrix containing the indexes of the vertices defining each face in the patch. Suppose you want to create the faces corresponding to the top. You can use
xaux = repmat(x(:),1,Ny);
yaux = repmat(y(:)',Nx,1);
zaux = repmat(zval,Nx,Ny);
vertices = [xaux(:),yaux(:),zaux(:)];
faces = [];
for indy = 1:Ny,
for indx=1:Nx,
faces=[faces;[indx,indx+1,indx+11,indx+10]+(indy-1)*10];
end,
end
patch('Vertices',vertices,'Faces',faces,'CData',reshape(temperature(:,:,end),Nx*Ny,1),'FaceColor','interp','EdgeColor','none');
You will need to repeat this for each side. You can use any grid you want. The interpolation may be rather unsatisfactory. Hope this helps.

댓글 수: 1

Simao Nobrega
Simao Nobrega 2015년 6월 21일
Hello Hugo,
Thank you for your answer. In the attached image you can see the temperature distribution of the top plane using contourf and your code. Maybe the problem is the interpolation that is being made in your code.

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

카테고리

질문:

2015년 6월 20일

댓글:

2015년 6월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by