Finding specific data for a given condition

I have this data set for which column 1 is time and column 2 is the number of atoms, and I'm trying to find variable N, which contains data that start at t>=0. I have done this:
index = find(Data >= 0, 1, 'first');
Ndecay = Data(index:end);
but I only get a row of data that corresponds to the time, rather than two rows, which should correspond to both time and number of atoms. How can I find the number of atoms corresponding to times at t>=0?

답변 (1개)

KSSV
KSSV 2021년 6월 7일
편집: KSSV 2021년 6월 7일

0 개 추천

Let data be your m*2 array. To get number of atoms at t = 0, you can use interp1.
t = data(:,1) ; % time
N = data(:,2) ; % Number of atoms
ti = 0 ; % N is required here
Ni = interp1(t,N,ti)
[ti Ni]
If you want to use find and index.
idx = t==0 ;
data(idx,:)

댓글 수: 2

gps
gps 2021년 6월 7일
편집: gps 2021년 6월 7일
@KSSV when I use this, I just get [0, 1121600], which is correct, but how can I find all the values for when t >= 0? So, I would have a matrix of values corresponding to t>=0 and the respective number of atoms at each time
KSSV
KSSV 2021년 6월 7일
idx = t>=0; data(idx,:)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

질문:

gps
2021년 6월 7일

댓글:

2021년 6월 7일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by