3D graphic dots in Matlab

I want to display 3D dots in Matlabin different colors depending on the value. I have the following code, but this does not work because plot3da vector is needed.

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 it in matlab?

+5
source share
1 answer

I would use

scatter3(x,y,z,ones(size(x)),data,'filled')

This will display all points of the same size and color them according to the data value using the current color palette. You can also use the data to scale the size of each point.

scatter3(x,y,z,data.^-2,data,'filled')
+9
source

All Articles