Generating scalar volume data, now in x,y,z,v columns
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This seems to be a common problem to which I found no direct answer.
I'm trying to visualize a data set of energy values depending on xyz-location, therefore a 4-D plot of scalar volume data. My data is now in form of a speardsheet with columns for x, y, z coordinates (each -0,5 - 0,4 on 0,1 intervals) and one for energy. In short, one row contains information on the location and corresponding energy. I have separated them in different variables (four 1000x1 arrays; X, Y, Z and E).
My goal would be to produce something like this. This far I have gathered that I should use isosurfaces with transparency and I think I'll manage that thanks to tutorial videos. However I have not found a way to produce necessary arrays for the job. I used
[x,y,z] = meshgrid(-0.5:0.1:0.4,-0.5:0.1:0.4,-0.5:0.1:0.4)
to genarate arrays for the coordinates, but I haven't found a way of making a corresponding array of my energies.
Ideal solution would of course read my datafile and produce correct energy array on its own, preferably even the x,y,z arrays. Since that may be hard to do(?), I would also be happy to be able to load data systematicly from one variable (1000x1) into "blank" 10x10x10 array, since I can sort my data beforehand in proper order when I know in which order the array is filled.
I'm fairly new to Matlab, so I would appreciate clear instructions, links to tutorials or documentation I didn't found on my own.
0 commentaires
Réponse acceptée
Patrick Kalita
le 14 Fév 2011
You will want to use the TriScatteredInterp class to interpolate the scattered data to a grid of points that is needed for isosurface. Here is an example:
% The point cloud data:
x = 2*rand(500,1) - 1;
y = 2*rand(500,1) - 1;
z = 2*rand(500,1) - 1;
e = x.^2 + y.^2 + z.^2;
% Generate the grid of points where the interpolated values will be calculated
[xg,yg,zg] = meshgrid(-1 : 0.05 : 1);
% Create the interpolating object
F = TriScatteredInterp(x, y, z, e);
% Do the interpolation
eg = F(xg,yg,zg);
% Now you can use isosurface with the gridded data
isosurface(xg,yg,zg,eg,0.75);
2 commentaires
Patrick Kalita
le 14 Fév 2011
Yes, adjusting the step size could help produce a smoother result. Having enough input (scattered) data points also helps. You can also set the 'method' property of the TriScatteredInterp object to 'natural' to get a smoother result, as well, at the expense of longer computation time.
Plus de réponses (2)
Matt Fig
le 14 Fév 2011
Try using NDGRID instead of MESHGRID. Read carefully the help for NDGRID, because the output order differs from that of MESHGRID.
1 commentaire
Andrew Newell
le 14 Fév 2011
I don't think this will work because E is probably not a regularly repeating value.
Andrew Newell
le 14 Fév 2011
Assuming you have read in X,Y,Z,E, and no grid points are missing, you can sort the points in a way that simulates MESHGRID as follows:
mat = [X(:) Y(:) Z(:) E(:)];
mat = sortrows(mat,[3 1 2]);
X = reshape(mat(:,1),[10 10 10]);
Y = reshape(mat(:,2),[10 10 10]);
Z = reshape(mat(:,3),[10 10 10]);
E = reshape(mat(:,4),[10 10 10]);
Now plot using
isovalue = 0.5; % or whatever
isosurface(X,Y,Z,E,isovalue)
2 commentaires
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!