4D plots in Matlab?

조회 수: 6 (최근 30일)
Ali
Ali 2013년 11월 13일
답변: Gautam 2024년 10월 23일
Hi, I was wondering whether one could plot a 4D line graph -- I am trying to track multiple cells in 3D (x, y, z position) over time, with all cells starting at origin (eg. t0(0,0,0), t1(0, 2, 2.5), t2(-1, 3, 4) etc..). This can easily be done in (x,y ,t) in Prism, but I would really like to plot the movement in 3 dimensions over time. Any help would be greatly appreciated!

답변 (2개)

Walter Roberson
Walter Roberson 2013년 11월 13일

Gautam
Gautam 2024년 10월 23일
Hello Ali,
If you want to represent the change in 3D position of a graphic over time, you can represent this using with an animation. Here's an example demonstrating this:
numTimePoints = 100;
t = linspace(0, 10, numTimePoints); % Time vector
x = sin(t);
y = cos(t);
z = t;
figure;
hold on;
grid on;
xlabel('X');
ylabel('Y');
zlabel('Z');
view(3);
line = plot3(x(1), y(1), z(1), 'b-', 'LineWidth', 2);
head = plot3(x(1), y(1), z(1), 'ro', 'MarkerSize', 8, 'MarkerFaceColor', 'r');
% Plot the trajectory as an animation
for i = 1:numTimePoints
line.XData = x(1:i);
line.YData = y(1:i);
line.ZData = z(1:i);
head.XData = x(i);
head.YData = y(i);
head.ZData = z(i);
pause(0.05);
end
This produces the following output:

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by