Scanning Matrix For Changes In Polarity
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Harry Eggo
 am 23 Aug. 2016
  
    
    
    
    
    Kommentiert: Harry Eggo
 am 23 Aug. 2016
            Just a bit of background: I have a very large matrix (106740x5). I need to process this into smaller files with a certain format to be compatible with other software. I have figured out how to produce the files in the right format but I've had another problem.
Basically, I need to break the files up so that if the changes in one of the column values changes direction (for example:
- 1
- 5
- 12
- 2 - 2 is less than 12 which contradicts the pattern of the previous values being bigger). When a direction change does occur, I need to break the matrix at this point and output it to a text file (which I know how to do).
Breaking the problem down, I can think of 2 main things that I need to know what to do to solve this problem:
- Identifying how many times that the column changes direction
- Identifying where these changes occur
There are other issues which I may come back to but I think that if I can figure out these parts, I will be able to sort things out.
0 Kommentare
Akzeptierte Antwort
  Robert
      
 am 23 Aug. 2016
        You could use diff and sign to create a logical array, then cumsum to convert that to a group index.
% where x is your column of data
ddx = diff(sign(diff(x)))~=0;
group = cumsum([1;0;ddx])
for ii = 1:group(end)
    isinthisgroup = group == ii;
    % your processing, file writing
end
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

