Dear MATLAB Experts,
I have encountered a problem in my research seems to be very tricky to me. Assume there is a matrix of size n*2 and the reduced form is needed. For simplicity let M represents our matrix. For each row of i, I need to calculate the difference of
and if the difference was smaller than a threshold value of 100, the the row numbers i and i+1 will be combined as a single row with the following elements:
Otherwise, both rows i and i+1 should be kept. The output of such a code is my desired reduced matrix. For example consider matrix M as
M = [5 180
200 300
330 600
1000 1400
1430 1500]
The code firstly combine the first two rows since they meet the criterion explained above;
M1 = [5 300
330 600
1000 1400
1430 1500]
In the second step, the code will combine the first two rows of the output matrix of step 1, i.e. M1 as follows
M2= [5 600
1000 1400
1430 1500]
This procedure continues so far so forth until we get the final desired output that is,
M_RED = [5 600
1000 1500]
I wonder if you can kindly help me figure it out. Any helps will be appreciated and I thank you for the time you take to assist me.
PS: What I actually need to get is the M_RED and I really do not care what the M1 and M2 and other matrices look alike. I just introduced them for the sake of better illustration.