Plot 4D matrix

1 Ansicht (letzte 30 Tage)
emko
emko am 10 Mär. 2016
Kommentiert: Walter Roberson am 10 Mär. 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by