How to plot a 4D plot (X , Y , Z and Intensity) ??

1 view (last 30 days)
Abdullah Malik
Abdullah Malik on 13 Oct 2015
Answered: Ayush on 5 Dec 2024
I have like 4 Columns (X,Y,Z and Intensity). How can I plot a 4D plot??
-5.000000e-03 -5 -2 1808724575000000 -4.989990e-03 -5 -2 1771033352400000 -4.979980e-03 -5 -2 1726418476100000 -4.969970e-03 -5 -2 1675286124200000 -4.959960e-03 -5 -2 1618110215600000 -4.949950e-03 -5 -2 1555428767400000 -4.939940e-03 -5 -2 1487838612700000 -4.929930e-03 -5 -2 1415988772600000 -4.919920e-03 -5 -2 1340576095300000
Thanks...

Answers (1)

Ayush
Ayush on 5 Dec 2024
Hi,
To plot a 4D plot where you have columns for X, Y, Z, and Intensity, you can use the “scatter3” function, which allows you to visualize data in three dimensions and use the fourth dimension to control the colour or size of the markers. Refer to an example implementation for a better understanding:
% Define your data
X = [-5.000000e-03, -4.989990e-03, -4.979980e-03, -4.969970e-03, -4.959960e-03, -4.949950e-03, -4.939940e-03, -4.929930e-03, -4.919920e-03];
Y = [-5, -5, -5, -5, -5, -5, -5, -5, -5];
Z = [-2, -2, -2, -2, -2, -2, -2, -2, -2];
Intensity = [1808724575000000, 1771033352400000, 1726418476100000, 1675286124200000, 1618110215600000, 1555428767400000, 1487838612700000, 1415988772600000, 1340576095300000];
% Create a 3D scatter plot
scatter3(X, Y, Z, 36, Intensity, 'filled');
% Add labels and title
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('4D Plot using scatter3');
% Add a colorbar to show the intensity scale
colorbar;
colormap jet; % You can change the colormap as needed
For more information on the “scatter3” function refer to the below documentation:

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!