Hi all, I have a standart cubic grid x, y, z and I have a temperature associated to each triplet. So my database is in 4D (x,y,z,T). I was able to visualize the temperature with scatter3, but it is not the representation I want...
I would like to use slice() or a function like this to be able to visualise different plane inside the data. But when I try to call the slice function, they ask for volumetric data insteat of array. I search for ways to transform my data in volumetric data, but I didn't found anything...
My question is: is there a way to transform my data into a volumetric data so that I can have a sliced representation (using slice() or another similar function).
My data is linked to the message and
x=A(:,1);
y=A(:,2);
z=A(:,3);
T=A(:,4);
Thank you in advance for your help!

 채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2019년 5월 7일

0 개 추천

To use slice you first have to re-interpolate your data to a regular 3-D grid. Depending on your matlab-version you can use: griddata, TriScatteredInterp, scatteredInterpolant. They have slightly different calling syntax. This is how I would use scatteredInterpolant:
F = scatteredInterpolant(A(:,1:3), T,'natural');
X = linspace(min(A(:,1)),max(A(:,1)),59);
Y = linspace(min(A(:,2)),max(A(:,2)),61);
Z = linspace(min(A(:,1)),max(A(:,1)),63);
[X,Y,Z] = meshgrid(X,Y,Z);
T3D = F(X,Y,Z);
slice(X,Y,Z,T3D,12,32,43),shading flat
HTH

댓글 수: 4

Gab D
Gab D 2019년 5월 8일
Hi Bjorn,
Thank you very much! It worked perfectly.
I tried with griddedInterpolant() since I though I had gridded data, but it didn't work. I went back to scatteredInterpolant() and it worked! After that, I didn't try the other function you proposed. If I have r2018a, do you recommend scatteredInterpolant?
Slice_test.jpg
Bjorn Gustavsson
Bjorn Gustavsson 2019년 5월 8일
편집: Bjorn Gustavsson 2019년 5월 8일
Great that it worked. For legacy-reasons (tardiness and rumours about HG2) I'm still working in an older release than 2018 - so I don't know if there's additional new functions for scattered interpolation, but Mathworks are usually very good with documenting new functions doing similar tasks in the SEE ALSO-section of the help - so check the help for scatteredInterpolant and see if you're lead somewhere further. The functionality should be pretty much the same, perhaps with improved smoothness, speed and whatnot...
Gab D
Gab D 2019년 5월 8일
This is how I got the idea to try the griddedInterpolant() function before the scatterInterpolant(). I agree that the help function and the SEE ALSO tab are very usefull!
Thank you again for your help!
Bjorn Gustavsson
Bjorn Gustavsson 2019년 5월 8일
My pleasure!

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

추가 답변 (0개)

카테고리

제품

릴리스

R2018a

질문:

2019년 5월 7일

댓글:

2019년 5월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by