0

I have a set of data e.g:

map (9,4) =

12.7779000000000    -45.3221000000000   -0.0264000000000000 0.330300000000000
12.9341000000000    -45.3222000000000   -0.0279000000000000 0.324300000000000
13.0903000000000    -45.3222000000000   -0.0294000000000000 0.330300000000000
13.2466000000000    -45.3222000000000   -0.0309000000000000 0.350000000000000
13.4028000000000    -45.3222000000000   -0.0324000000000000 0.350000000000000
13.5591000000000    -45.3222000000000   -0.0338000000000000 0.339800000000000
13.7153000000000    -45.3222000000000   -0.0352000000000000 0.361200000000000
13.8716000000000    -45.3222000000000   -0.0366000000000000 0.304400000000000
14.0278000000000    -45.3223000000000   -0.0380000000000000 0.350000000000000

the first column has the x-cordinates the second column has the y-cordinates the third column has the z-cordinates the fourth column is some value at that particular (x,y,z), so how can i plot this data in matlab?

Phonon
  • 12,549
  • 13
  • 64
  • 114
A. K.
  • 34,395
  • 15
  • 52
  • 89
  • 4
    possible duplicate of [matlab: how to use an array for coloring a plot](http://stackoverflow.com/questions/6570563/matlab-how-to-use-an-array-for-coloring-a-plot), which itself is a possible duplicate of [How to plot a 3D plot in MATLAB?](http://stackoverflow.com/questions/1809881/how-to-plot-a-3d-plot-in-matlab) – Amro Jul 28 '11 at 23:39
  • @Amro thanks for pointing out. Those links were also useful. – A. K. Jul 29 '11 at 06:27

1 Answers1

1

You have to use the scatter3 function. Here's an example Matlab gives:

[x,y,z] = sphere(16);
X = [x(:)*.5 x(:)*.75 x(:)];
Y = [y(:)*.5 y(:)*.75 y(:)];
Z = [z(:)*.5 z(:)*.75 z(:)];
S = repmat([1 .75 .5]*10,numel(x),1);
C = repmat([1 2 3],numel(x),1);
scatter3(X(:),Y(:),Z(:),S(:),C(:),'filled'), view(-60,60)

In your particular example,

data = map(9,4);
X = data(:,1);
Y = data(:,2);
Z = data(:,3);
C = data(:,4);
scatter3(X,Y,Z,10,C,'filled'); colorbar; shg;
Phonon
  • 12,549
  • 13
  • 64
  • 114