How to overcome the data length issue in the following code?

1 次查看(过去 30 天)
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 find the similar or the nearest Timestamps in the Head_Timestamps.xlsx hence on matching plot the corresponding data (head/Uy) hence save the timestamp, head, and Uy into new xlsx or csv file. I have tried the intern1 function so far in which I am having problem because in file Head_Timestamps.xlsx there are more data then the TimeStamps_Uy.xlsx. I am pasting the code and error below?
close all; clear all; clc;
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);
Head_dir = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_Head\Data_Raw\Head_Timestamps.xlsx';
a1 = readmatrix(Head_dir);
h_u = interp1(h,u,time_stamp_u)
Error using interp1>reshapeAndSortXandV (line 445)
X and V must be of the same length.
Error in interp1 (line 128)
[X,V,orig_size_v] = reshapeAndSortXandV(X,V);


Image Analyst
Image Analyst 2022-3-10
"I have 2 excel files named TimeStamps_Uy.xlsx and Head_Timestamps.xlsx." Yes, you have them, but we don't because you forgot to attach them.
h and u are not the same lengths. What are the sizes of those arrays
  2 个评论
Image Analyst
Image Analyst 2022-3-10
See -- h and u have different lengths. You need to pass in the full x first, then the full y, then the x values that you want the interpolated values for the third argument. So the full x and y must be the full signal that you have and must be the same length since you have a y for every x.


更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by