Filter löschen
Filter löschen

Linking two sets of data to be in line with eachother

1 Ansicht (letzte 30 Tage)
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!

Akzeptierte Antwort

Cameron Hudspith
Cameron Hudspith am 16 Okt. 2023
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"};

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 15 Okt. 2023
Perhaps
idx = interp1(loadValues1, 1:numel(loadValues1), loadValues2, 'nearest')
  1 Kommentar
Cameron Hudspith
Cameron Hudspith am 16 Okt. 2023
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

Melden Sie sich an, um zu kommentieren.

Tags

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by