Hi Amit,
I understand that you are facing an issue while plotting 3D data.
For plotting the position data (3D matrix) as circles using plot 3, the provided code in the question does not define the variables 'xt', 'yt' and 'zt'.
To generate the desired output, kindly consider modifying the code as shown below:
sensor_data = randi([1 10], 16, 16, 16);
xt = 1:16;
yt = 1:16;
zt = 1:16;
figure;
subplot(1, 2, 1);
plot3(xt, yt, zt, 'o');
grid on;
To plot a ‘1cm’ long line into both directions along the sensor’s orientation, Kindly refer to the following code:
figure;
hold on;
X_data = sensor_data(:, :, 1);
Y_data = sensor_data(:, :, 2);
Z_data = sensor_data(:, :, 3);
scatter3(X_data(:), Y_data(:), Z_data(:), 'o');
quiver3(X_data(:), Y_data(:), Z_data(:), X(:), Y(:), Z(:), 0.01, 'r');
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Sensor Data');
hold off;
Kindly adjust the above code by providing the actual sensor orientation vectors ‘x’, ‘y’ and ‘z’ as per your requirement.
The “quiver3” function in the above code takes the sensor positions as the starting points and the orientation vectors (X, Y, and Z) as the directions of the lines. The next argument '0.01' specifies the length of the lines as ‘1cm’. The 'r' argument sets the color of the lines to red.
For more information regarding the “quiver3” function, kindly refer to the following documentation:
I hope this answer helps you.