필터 지우기
필터 지우기

Linking two sets of data to be in line with eachother

조회 수: 1 (최근 30일)
Cameron Hudspith
Cameron Hudspith 2023년 10월 15일
답변: Cameron Hudspith 2023년 10월 16일
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