plotting coordinates vs. time and i need my time to run with or without loop function repeatedly.

조회 수: 5 (최근 30일)
hi,
i need to plot my corrdinates vs time. and my time to run with a loop function repeatedly. is there any other method for me to try without loop or any command options?

답변 (2개)

Shivam
Shivam 2025년 2월 20일
Hi Shane,
I am assuming that you have an array of coordinates to be plotted again a time vector, but without a loop.
The given workaround works for 100 points generated using sin function:
% Example data
time = 0:0.1:10;
coordinates = sin(time); % Example coordinate data array
% Plotting without a loop
figure;
plot(time, coordinates);
xlabel('Time');
ylabel('Coordinates');
title('Coordinates vs. Time');

Sam Chak
Sam Chak 2025년 2월 20일
Generally, coordinates can be specified in 2D (planar) or 3D (spatial) formats. If you wish to plot the spatial coordinates against the time vector, resulting in a 4D problem, this can be challenging to conceptualize according to conventional practices. However, if your goal is to visualize the spatial trajectory of the particle over a time interval, you may consider using a parametric plot approach.
Here is my visualization of a particle moving along a spiral path as it approaches the event horizon of a black hole. This representation may be incorrect, as the spiral motion may not stick to the exponential decay law.
syms t
xt = exp(-t/10).*sin(5*t);
yt = exp(-t/10).*cos(5*t);
zt = -t;
fplot3(xt, yt, zt, [0 30])
xlabel('X'), ylabel('Y'), zlabel('Z')
title('Particle orbits and spiral inwards as it falls into the black hole')

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by