Plotting speed data in 3D (Cube)

6 views (last 30 days)
Keith Hay
Keith Hay on 10 Aug 2022
Edited: Keith Hay on 10 Aug 2022
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
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')
Keith Hay
Keith Hay on 10 Aug 2022
Edited: Keith Hay on 10 Aug 2022
My bad. I shouldve been more clear about what I meant with the cube.
Say I have an the xyz origin axis at the center of a cube such that it divides the cube into 8 different sections as below.
Say I want j = 2:5 in the front facing quadrant, one in the center of (-,-,+), one in the center of (+,-,+), one in the center of (-,-,-) and finally one in the center of (+,-,-). My previous code was graphing all these speeds at the same time. However, I want to change that to displaying the actual numbers in the desired location. As in when t=2, j is 0.46 m/s and that is displayed as a number, in the center of (-,-,+) and so forth.

Sign in to comment.

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!