Linking two sets of data to be in line with eachother

1 次查看(过去 30 天)
Hey, I have two tables, each with a column for load and position. I'm hoping to use one set of load data, to search the other table for the nearest load value and extract it's relative position. I would then subtract that position from the original tables position (likely into a new array).
I believe this should be done with indexing, but I'm pretty confused on the subject (especially considering the load values aren't exactly equal, I just need to index to the cloest value)
Any tips would be helpful!

采纳的回答

Cameron Hudspith
Cameron Hudspith 2023-10-16
The following function is the solution to my problem. I was able to put it into a loop to apply the result to every row of my dataset. Thanks to everyone who helped.
[~,idx] = min(abs(PressingPlate_FP{:,"LoadN"}-Control_FP{i,"LoadN"}));
result = PressingPlate_FP{idx, "Positionmm"};

更多回答(1 个)

Walter Roberson
Walter Roberson 2023-10-15
Perhaps
idx = interp1(loadValues1, 1:numel(loadValues1), loadValues2, 'nearest')
  1 个评论
Cameron Hudspith
Cameron Hudspith 2023-10-16
I believe that is on the right track, but I can't get the function to work
i=1;
idx = interp1(PressingPlate_FP(:,"LoadN"), PressingPlate_FP(:,"Positionmm"), Control_FP{i,"LoadN"}, 'nearest');
In that code I'm hoping interp1 will search the load column of the PressingPlate_FP table for the nearest value to Control_FP{i,"LoadN"}, then return The value of the position column of PressingPlate_FP directly next to the load value
The function is currently giving me an error

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by