3-D Countour Plot based on velocity data

I have data consist of X(x coordinate) Y(y coordinate) Z(z coortinate) U(velocity).
there is four z height (0.05,0.18,0.31 and 0.44 )
I tried to create 3D countour plot with given code but it fails.
xyzu = readmatrix('velocity3d.txt');
xyzu = [xyzu(1,:); xyzu];
x=xyzu(:,1);
y=xyzu(:,2);
z=xyzu(:,3);
u=xyzu(:,4);
% [Ux,xix] = unique(x);
% dxix = diff(xix)
Xm = reshape(x, 6, []);
Error using reshape
Product of known dimensions, 6, not divisible into total number of elements, 221.
Ym = reshape(y, 6, []);
Zm = reshape(z, 6, []);
Um = reshape(u, 6, []);
figure
contour3(Xm,Ym,Zm,Um)
colormap(turbo)
colorbar
Which code I need to create 3D velocity countour plot? Thank you.
Note: I uploaded my data as an attachment.

 Respuesta aceptada

Torsten
Torsten el 25 de Dic. de 2022
Editada: Torsten el 25 de Dic. de 2022
xyzu = readmatrix('velocity3d.txt');
x=xyzu(:,1);
y=xyzu(:,2);
z=xyzu(:,3);
u=xyzu(:,4);
F = scatteredInterpolant(x,y,z,u);
xq = linspace(min(x),max(x),20);
yq = linspace(min(y),max(y),20);
zq = linspace(min(z),max(z),20);
[xq yq zq] = meshgrid(xq,yq,zq);
uq = F(xq,yq,zq);
xslice = mean(x);
yslice = mean(y);
zslice = mean(z);
slice(xq,yq,zq,uq,xslice,yslice,zslice)
colormap(turbo)
colorbar

7 comentarios

JACK LONDON
JACK LONDON el 25 de Dic. de 2022
Thank you.
Is there a way to show in this format:
Torsten
Torsten el 25 de Dic. de 2022
Editada: Torsten el 25 de Dic. de 2022
Where is z and where is u ?
I seems this is a surface plot for (x,y,u) data where u is standard-deviation wave height.
But you have (x,y,z,u) data.
JACK LONDON
JACK LONDON el 25 de Dic. de 2022
Editada: JACK LONDON el 25 de Dic. de 2022
Note: maybe source file need to be revised. sorting for z values. I am arranging now.
In the data 3th column is z height and 4th column is v velocity.
There are x and y values for four different z values; (0.05, 0.18, 0.31 and 0.44 m)
For the z =0.05; x,y and u values should shown in the 3d countour plot
For the z =0.18; x,y and u values should shown in the 3d countour plot
For the z =0.31; x,y and u values should shown in the 3d countour plot
For the z =0.44 ; x,y and u values should shown in the 3d countour plot
Thanks.
Torsten
Torsten el 25 de Dic. de 2022
Editada: Torsten el 25 de Dic. de 2022
So you want four surface plots like the one above - each for a different height ?
Then prepare four input files - each for constant z - and use Voss's answer to your previous question to plot with contourf or surf.
Torsten
Torsten el 25 de Dic. de 2022
I tried Voss's answer but I can t figure out how I combine for four different z values.
You don't have to combine anything. Make four files of the one you posted and apply Voss's code to each file separately.
JACK LONDON
JACK LONDON el 25 de Dic. de 2022
Editada: JACK LONDON el 25 de Dic. de 2022
In this case there is not 3d countour only 4 different 2d velocity countour seperately. I need 3d countour.
Torsten
Torsten el 25 de Dic. de 2022
Editada: Torsten el 25 de Dic. de 2022
Can you give a link to a plot you are talking about ? The one you posted is a 3d surface plot you can get for each z-value separately, but not for all z-values together.
This is all you can get:
xyzu = readmatrix('velocity3d.txt');
x=xyzu(:,1);
y=xyzu(:,2);
z=xyzu(:,3);
u=xyzu(:,4);
F = scatteredInterpolant(x,y,z,u);
xq = linspace(min(x),max(x),100);
yq = linspace(min(y),max(y),100);
zq = linspace(min(z),max(z),100);
[xq yq zq] = meshgrid(xq,yq,zq);
uq = F(xq,yq,zq);
zslice = [0.05,0.18,0.31,0.44];
h = slice(xq,yq,zq,uq,[],[],zslice);
colormap(turbo)
colorbar
set(h,'EdgeColor','none')

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 25 de Dic. de 2022

Editada:

el 25 de Dic. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by