Realignment of columns in a matrix with one (or more) values out of sync -- a "voting" algorithm?

K
Kennedy · Mar 5, 2021 · 1.8K views
Question
I have what I think is a rather simple question. I have a three column  matrix of the times of peaks calculated from three common-time-base vectors. I know how many peaks there should be, and that limits the calculation. On occasion there is a misalignment like the following:     13 17 15 24 36 33 34 56 59 59 75 75 75 96 97 97 113 114 134 134 135 The “24” is inserted, and a value of “113” or “114” is dropped in the first column. The numbers are close but not exact, and a mean or median of two out of three would be a good guess. Any suggestions on how to implement such a realignment?
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 16, 2026
Perhaps something like,
 
 
nX = zeros(size(X));
m = median(X,2);
for K = 1 : size(X,2)
  nX(:,K) = interp1(X(:,K), X(:,K), m);
end
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!