Subtracting pairs of adjacent columns in an array without overlap
2 views (last 30 days)
Show older comments
I am relatively new to Matlab and I am trying to get the difference between adjacent columns from an array where the columns alternate by condition (i.e., a contrast between experimental and control conditions). I have found code that on the surface seems to be what I am looking for (e.g., https://www.mathworks.com/matlabcentral/answers/743387-how-to-substract-every-two-adjacent-column-from-a-matrix?s_tid=srchtitle&s_tid=mwa_osa_a) but it actually calculates the difference for columns 1-2, 2-3, 3-4 , etc. but I want 1-2, 3-4, 5-6, etc. without any overlap.
e.g., a [72, 324]
b = a(:1:end-1) - a(:,2:end)
I am trying to get an output array with half the number of original columns (i.e., [72, 162])
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!