필터 지우기
필터 지우기

How to make a sequence of time and the corresponding data from a data set where time is not provided sequentially

조회 수: 3 (최근 30일)
I have some time series data for velocity, density for 30 mins time gap. But when I plotted, I see the time overlaps. How can I make the data set sequential for time with the corresponding data?
Can I do it without interpolation?
Thanks for help!
Suppose time = [1, 5, 10, 15, 20, 16, 21, 26, 31] and velocity and density are for the corresponding time.
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2024년 2월 21일
이동: Dyuman Joshi 2024년 2월 24일
Sort the time data, and use the indices obtained (2nd output of sort) to get the corresponding velocity and density values, and plot accordingly.

댓글을 달려면 로그인하십시오.

채택된 답변

Aquatris
Aquatris 2024년 2월 21일
편집: Aquatris 2024년 2월 21일
You cannot fill the gaps in your data without physically taking more data or interpolating.
However if your problem is to order the time vector so that it is strictly increasing then you can use sort function:
time = [1, 5, 10, 15, 20, 16, 21, 26, 31];
data = [10 20 25 30 35 27 36 40 45];
[timeSorted,idx] = sort(time);
dataSorted = data(idx);
subplot(2,1,1),plot(time,data,'bx-'),xlim([0 32]),title('Original Data')
subplot(2,1,2),plot(timeSorted,dataSorted,'rx-'),xlim([0 32]),title('Sorted Data')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by