Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Removing repeating data points but keeping the first and last ones
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
Hello, say I have matrix with repeating parts in the frist and second row and all zeros in the third
A=1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,3,4,5,6
     9,9,9,9,9,9,9,9,9,2,3,4,5,6,7,8,9,8,2,2,2,2
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
I want to keep the columns where there is no repeating in the column before and after. Additonally, I want to keep the columns where the repeating starts and ends. The resulting matrix would look like this in the end
 A=1,9,1,1,3,6
     9,9,2,8,2,2
     0,0,0,0,0,0
How would I get this
thank you 
2 Kommentare
  Image Analyst
      
      
 am 20 Mai 2019
				What if your criteria would result in the first and second row having different numbers of elements?
  Adam Danz
    
      
 am 20 Mai 2019
				I wondered that, too.  For example, 
A=[  1,2,3,4,5,6,7,1,1,1,1,1,1,1,1,1,1,1,3,4,5,6;
     9,9,9,9,9,9,9,9,9,9,9,4,5,6,7,8,9,8,2,2,2,2;
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
 %                 ^ ^ ^ ^
My answer removes columns in any of the rows have repeats (but keeps the first and last ones). 
so, 
Ap =      1     1     3     6
          9     8     2     2
          0     0     0     0
Antworten (1)
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


