MATLAB: Generating scalar volume data, now in x,y,z,v columns

4-darrayMATLABscalar volume data

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 1000×1 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 (1000×1) 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.

Best Answer

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);