I want to plot 3D points in Matlab in different colors depending on a value. I’ve got following code, but this does not work because plot3d needs a vector.
x = vdhf_data.data(:,1);
y = vdhf_data.data(:,2);
z = vdhf_data.data(:,3);
data = vdhf_data.data(:,4);
grid on
hold all
for k=1:length(x)
if data(k) < 6
plot3d(x(k), y(k), z(k), 'ws--', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r')
else
plot3d(x(k), y(k), z(k), 'ws--', 'MarkerEdgeColor', 'g', 'MarkerFaceColor', 'g')
end
end
How to do that in Matlab?
I would use
This will plot all the points at the same size and color them according to the value of data, using the current colormap. You can also use data to scale the size of each point.