Plot 4D matrix

1 view (last 30 days)
emko
emko on 10 Mar 2016
Commented: Walter Roberson on 10 Mar 2016
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

Accepted Answer

Walter Roberson
Walter Roberson on 10 Mar 2016
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.
  3 Comments
emko
emko on 10 Mar 2016
Can be same done with slice, and how?
Walter Roberson
Walter Roberson on 10 Mar 2016
No, slice() is for extracting data from 3D arrays, not from 4D arrays.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!