Plotting speed data in 3D (Cube)
6 views (last 30 days)
Show older comments
I've got data for the speed with which air flows through different locations in a box. I began by a simple code to graph speed as follows.
clc
clear all
D = readtable("CubePlot","VariableNamingRule","preserve");
Df = table2array(D);
for i=1:1:length(Df)
t=Df(i,1);
for j=2:5;
speed=Df(i,j);
plot(t,speed,'.')
drawnow
hold on
end
end
This plots all the air speeds at time t, followed by all the air speeds at time t+1 and so on. Ive got several hundreds of data points so instantaneous comparison with this graph is not reasonable.
How can I represent this data in a cube with different locations displaying their respective speeds with passing time?
2 Comments
Karim
on 10 Aug 2022
At first glance you have 2D data? One dimension is time and the other is speed?
To make a bit more clear you could plot the curves, and not only the data points:
D = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1093160/CubePlot.xlsx","VariableNamingRule","preserve");
Df = table2array(D);
figure
plot(Df(:,1), Df(:,2:end))
grid on
xlabel('t')
ylabel('speed')
However, if you want to seperate them and plot them as 3D curves, you could create a space (see below). However i'm not sure if this makes it easier to interpret.
figure
hold on
for i = 2:6
Space = i * 10 * ones(size(Df(:,1)));
plot3(Df(:,1), Space,Df(:,i))
end
hold off
grid on
view(3)
xlabel('t')
zlabel('speed')
Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!