Plot of head against velocity data based on timestamp similarity

조회 수: 1 (최근 30일)
muhammad choudhry
muhammad choudhry 2022년 3월 10일
댓글: Jon 2022년 3월 10일
Hi,
I have 2 excel files named TimeStamps_Uy.xlsx and Head_Timestamps.xlsx. In file one: TimeStamps_Uy.xlsx column 1 have a Timestamps and column 2 have the velocity data. In file two: column 1 have a Timestamps and column 2 have the Head data. I want to use TimeStamps_Uy.xlsx file and all of its Timestamps to fine the similar Timestamps in the Head_Timestamps.xlsx hence on matching plot the corresponding data (head/Uy) from both files column 2 for the same or near enough time stamp hence save the timestamp, head, and Uy into new xlsx or csv file. How would I do that? I have attached both the xlsx file in this post. I have tried but getting nowhere! Code below is just show the path and normal reading of data from column.
Code so far:
Uy_dir = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_PIV\5-AverageFilter_VelocitiesExtration\Point_Velocities\Uy\TimeStamps_Uy.xlsx';
a = readmatrix(Uy_dir);
x=a(:,1);
y=a(:,2);
Head_dir = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_Head\Data_Raw\Head_Timestamps.xlsx';
a = readmatrix(Head_dir);
x=a(:,1);
y=a(:,2);

채택된 답변

Jon
Jon 2022년 3월 10일
편집: Jon 2022년 3월 10일
First read in both of your datafiles.
Then use MATLAB function interp1 to interpolate values at times matching the times in one of the data files (doesn't matter which one)
So suppose that you have vectors tu, u for times and corresponding velocities and also th, h for times and corresponding head values. Then you could interpolate values of head at times matching those in the velocity data using
hq = interp1(th,h,tu)
and then if you wanted to plot head vs velocity you could plot the interpolated head values against the velocity values
plot(u,hq)
  댓글 수: 7
muhammad choudhry
muhammad choudhry 2022년 3월 10일
Thanks alot for the explaination, yes I have accepted the answer. Thanks again!
Jon
Jon 2022년 3월 10일
Great, good luck with your experiment.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by