# Align different starting point to zero

5 Ansichten (letzte 30 Tage)
Jaehwi Bong am 4 Jun. 2019
Kommentiert: Jaehwi Bong am 4 Jun. 2019
I have a matrix , 7096*3 double.
At a first column, numbers represent same particles with different number. I have 168 particles and each of them has different starting time points(second column) with intensity value(third column). In the case of 40th particles, it starts from 2.1960 (see, the matrix, 40 from first column and 2.196 from second column).
I'd like to align those data to zero as the starting point. I need to find inital value or minimum value of time column of each particle and substract them. And make new matrix, probably. How can I do for that?
40 2.196 51950
40 3.294 51728
40 4.392 50899
40 5.490 50869
40 6.588 51741
-> What I want to do is
40 0 51950
40 1.098 51728
40 2.196 50899
40 3.294 50869
40 4.392 51741
number=unique(B(:,1));
tn=length(unique(B(:,1)));
for k=1:tn
B(B(:,1)==number(k),2)-min(B(B(:,1)==number(k),2));
end
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Sayyed Ahmad am 4 Jun. 2019
try with find and index
for i=1:tn
ind=find(B(:,1)==number(i))
y=min(B(ind,2));
B(ind,2)=b(ind,2)-y;
end
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Jaehwi Bong am 4 Jun. 2019
Thank you very much!

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Matrices and Arrays 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!

Translated by