However, I don't know why there are 300 data, so I create random 100 data in [0:0.1:1] X [0:0.1:1]
, and there are only 100 of them.
As far as I know, are two ways to plot 3-D figures with these data. Just like Cris Luengo says, if you need a scatter/plot, use scatter3
or plot3
, they are similar to ordinary plot
. But if you need a surface, you have to change the struct of the data and use mesh
or surf
.
%%Init
clc; clear;
%%Random Data
y=0.1:0.1:1;
C=[0 0];
for i=1:10
X=[ones(1,10)*i*0.1; y]';
C=[C;X];
end;
C=[C(2:101,:) rand(100,1)];
%%plot scatter/lines
figure()
plot3(C(:,1),C(:,2),C(:,3),'r-')
hold on
plot3(C(:,1),C(:,2),C(:,3),'b.')
%%plot a Surface
figure()
[X,Y] = meshgrid(0.1:0.1:1,0.1:0.1:1);
nC=C(1:10,3)
for i=2:10
nC=[nC C((i-1)*10+1:i*10,3)];
end;
mesh(X,Y,nC)
Hope this code helps.