Reputation: 73
i have a data file which contains the x,y,z coordinates of the variable V
x y z V
0 0 0.500000000000000 3.91743717285931
0.0500000000000000 0 0.500000000000000 4.82593865902504
0.100000000000000 0 0.500000000000000 5.03874568425820
0.150000000000000 0 0.500000000000000 4.84015746128314
0.200000000000000 0 0.500000000000000 4.31320834211277
0.250000000000000 0 0.500000000000000 4.71007310928003
0.300000000000000 0 0.500000000000000 5.68353172300361
0.350000000000000 0 0.500000000000000 6.93907354201857
0.400000000000000 0 0.500000000000000 1.69713115593222
0.450000000000000 0 0.500000000000000 0
0.500000000000000 0 0.500000000000000 0
0.550000000000000 0 0.500000000000000 0
0.600000000000000 0 0.500000000000000 0.485840981213434
0.650000000000000 0 0.500000000000000 1.30265381445392
0.700000000000000 0 0.500000000000000 1.73892191516507
0.750000000000000 0 0.500000000000000 1.78720066586633
0.800000000000000 0 0.500000000000000 0.401158585618868
0.850000000000000 0 0.500000000000000 4.33700792828408
0.900000000000000 0 0.500000000000000 5.76388423361443
0.950000000000000 0 0.500000000000000 2.41835943394263
as the data file which contains the values are all in separate columns i am trying something this to convert the whole doamin into a single 3d doamin.
input = importdata('lci_000210.dat',' ',3);
nx = 96;
ny = 96;
nz = 49;
x = input.data(:,1);
y = input.data(:,2);
z = input.data(:,3);
Lci = input.data(:,4);
L3d = reshape(Lci,[nx,ny,nz]);
x3d = reshape(x,[nx,ny,nz]);
y3d = reshape(y,[nx,ny,nz]);
z3d = reshape(z,[nx,ny,nz]);
[x3d,y3d,z3d,L3d] = flow;
xslice = 5;
yslice = 0;
zslice = 0;
slice(x,y,z,Lci,xslice,yslice,zslice);
view(25,20);
colormap jet
colorbar
this however keeps throwing up the following error
V must be a 3-D array.
So i am really unsure how to deal with the dataset, what i really would like is to take a slice at any location through the dataset, but still show the 3d doamin. i have attached a picture showing how i would like the slice to be represented. I have tried re-shape but that is not working, i jave done re-shape as the data is in columns and re-shape turns it into a 3d matrix as it should be.
The data is from a fluid flow simulation
Any advice and help will be extremely helpful on how to get the slices from this data set.
in the image it shows a contourslice at y=0, but i would like it to be shown at any y position, so the it can be seen where the slice has been taken from the full 3d picture
Upvotes: 1
Views: 1624
Reputation: 1845
The problem seems to be your x3d and y3d are reversed.
slice(y3d,x3d,z3d,L3d,[],[],[0.1 0.3 0.5]);
ax=gca;
ax.Children(1).LineStyle='none';
ax.Children(2).LineStyle='none';
ax.Children(3).LineStyle='none';
view(25,20);
colormap jet
colorbar
For contours just give it a value to draw the contour of.
figure(2);clf
contourslice(y3d,x3d,z3d,L3d,[],[],[0.1 0.3 0.5],[10 20]);
view(25,20);
For contourplots I found a different solution. Not as straightforward as the other two.
zax = squeeze(z3d(1,1,:));
zvals=[2 13 24];
figure(1);clf;hold on
for ct = 1:length(zvals)
%plot the contour
contourf(L3d(:,:,zvals(ct)),[0 10 20]);
ax=gca;
ax.Children(1).XData=x3d(:,1,1); %set x axis
ax.Children(1).YData=y3d(1,:,1); %set y axis
ax.Children(1).ContourZLevel=zax(zvals(ct)); %put at correct z
end
view(25,20);colormap
Thanks to Amro's answer here: plot multiple 2d contour plots in one 3d figure [Matlab]
Upvotes: 2
Reputation: 73
i just want something like this, so a filled contour.
Upvotes: 1