MATLAB: Plot 4D matrix

MATLABplot

Hey all, I am trying to plot this matrix… any ideas how to do this???
x1=linspace(8000,12000,10); % vEa
z1=linspace(0.15,0.25,10); % vva
y1=linspace(1000,3000,10); % vEc
c1=linspace(0.15,0.25,10); % vvc
[X1,Y1,Z1]=meshgrid(x1, y1, z1);
for i=1:length(x1)
for j=1:length(y1)
for k=1:length(z1)
for l=1:length(c1)
f(i,j,k,l)= this is some Cost function which depends on this x1,y1,z1,c1 !!!
end
end
end
end

Best Answer

Your
[X1,Y1,Z1]=meshgrid(x1, y1, z1);
is not being used. If you could vectorize your cost function you would need to use
[X1,Y1,Z1,C1] = ndgrid(x1, y1, z1, c1);
Anyhow...
With 4 input dimensions and 1 result, you are dealing with plotting 5 dimensional points. There is no good way of doing that.
About the closest you can get is to scatter3() on 3 of the dimensions, with 1 of the dimensions used for point size and the remaining dimension used for color. In order for that to show up, you will need to use f as one of the spatial coordinates, such as
X1v = X1(:);
Y1v = Y1(:);
Z1v = Z1(:);
C1v = C1(:);
fv = f(:);
scatter3(fv, Y1v, Z1v, X1v, C1v)
it probably will not look all that good.
Related Question