find where number changes in a matrix
Ältere Kommentare anzeigen
I have a matrix of +1 and -1 values. I want to find where the number flips from 1 to -1 or vice versa where the change is a change from column to column.
X=[...
1 1 1 1;
1 -1 1 1;
1 1 1 -1;
1 1 1 1]
the answer should be [2,2],[2,3]and [3,4]. I tried
find(diff(X)==2);
find(diff(X)==-2);
Any help is appreciated
Akzeptierte Antwort
Weitere Antworten (1)
the cyclist
am 23 Mär. 2013
One way:
[i j] = find(abs([zeros(4,1),diff(X,[],2)])==2)
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!