How to substract every two adjacent column from a matrix

1 view (last 30 days)
Hi,I new to matlab and i couldn't solve this issued. I have a matrix of [3750,666] and I need to subract every two adjacent column and normalize it. Can somebody help me with this?

Accepted Answer

Matt J
Matt J on 12 Feb 2021
y=(x(:,3:N)-x(:,1:N-2))./x(:,2:N-1);
  4 Comments
MUHAMMAD SYAKIR YUSRI
MUHAMMAD SYAKIR YUSRI on 12 Feb 2021
i have a matrix x with MxN = (3750X666) and i want to subract every two adjacent column x(:,3:N)-x(:,1:N-2)) and create a new matrix with the same dimension, how can i do it?
Matt J
Matt J on 12 Feb 2021
Edited: Matt J on 12 Feb 2021
i want to subract every two adjacent column x(:,3:N)-x(:,1:N-2))
Are you asking here for a different computation than the one you originally posted? If not, un-Accept the answer and explain in what way the answer doesn't accomplish what you're after.

Sign in to comment.

More Answers (1)

Matt J
Matt J on 12 Feb 2021
Perhaps this is what you were looking for,
y = conv2(x,[1,0,-1],'same')./x;

Tags

Community Treasure Hunt

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

Start Hunting!