I have 2 columns, i want to find the maximum in the second column and then know what value it is next to on the first column
조회 수: 14 (최근 30일)
이전 댓글 표시
Hello. I have two columns that are 1221 rows long. The absorbance is on the first column and the wavelength on the second column. I want to find the maximum value for wavelength between 651:1221. Then i want to know the value of the absorbance next to it. When i know the value of that absorbance i need the absolute value of that absorbance subtracted by 520. How do I do this? Thanks for your help!
댓글 수: 0
답변 (2개)
Kevin Holly
2023년 3월 22일
편집: Kevin Holly
2023년 3월 22일
Generate data
M = rand(1221,2)*1000;
Find max value and it's index in rows 651 to 1221 in the 2nd column of M.
[maxvalue, index] = max(M(651:1221,2))
Look at the first column value at that specific row. Then take the absolute value and subtract 520.
Answer = abs(M(index+650,1))-520
댓글 수: 5
Kevin Holly
2023년 3월 22일
Generate data
M = rand(1221,2)*1000;
Did you want to normalize based on the absorbance at the max wavelength?
Find max value and it's index in rows 651 to 1221 in the 2nd column of M.
[maxvalue, index] = max(M(651:1221,2))
absorbance_at_max_wavelength = M(index+650,1)
norm_absorbance = M(:,1)/absorbance_at_max_wavelength;
Look at the first column value at that specific row. Then take the absolute value and subtract 520.
Answer = abs(norm_absorbance(index+650,1))-520
Or did you want to normalize based on the max absorbance?
M(:,1) = M(:,1)/max(M(:,1))
Answer = abs(M(index+650,1))-520
the cyclist
2023년 3월 22일
% Pretend data
aw = rand(1221,2) + 250;
% Max 2nd col in range, with index
[maxW,idx] = max(aw(651:1221,2));
% Absorbance for that value of W
aAtMaxW = aw(650+idx,1);
% Subtract 520 and take absolute value
a520 = abs(aAtMaxW - 520)
댓글 수: 4
the cyclist
2023년 3월 22일
I'm not sure what "redo the data to have the new absorbance" means. Do you want to divide all the absorbance values by this value we helped you calculate? If so, then
data(:,1) = data(:,1)/peak_520
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!