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

15 visualizzazioni (ultimi 30 giorni)
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!

Risposte (2)

Kevin Holly
Kevin Holly il 22 Mar 2023
Modificato: Kevin Holly il 22 Mar 2023
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))
maxvalue = 999.2946
index = 488
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
Answer = 319.0898
  5 Commenti
Kevin Holly
Kevin Holly il 22 Mar 2023
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))
maxvalue = 999.5113
index = 186
absorbance_at_max_wavelength = M(index+650,1)
absorbance_at_max_wavelength = 753.0649
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
Answer = -519
Or did you want to normalize based on the max absorbance?
M(:,1) = M(:,1)/max(M(:,1))
M = 1221×2
0.2738 682.4881 0.6873 114.3255 0.8356 60.1602 0.1472 987.4319 0.5303 475.9494 0.0270 282.6909 0.7116 464.6401 0.5602 833.6767 0.4480 193.7245 0.8933 702.8031
Answer = abs(M(index+650,1))-520
Answer = -519.2466
Chelsie Boodoo
Chelsie Boodoo il 22 Mar 2023
Modificato: Chelsie Boodoo il 22 Mar 2023
So i want the data to be normalized like this absorbance= data(:, 2)/(max(data(321:1221, 2)));
i want to leave the first column the same in data but replace the second column with the data from absorbance= data(:, 2)/(max(data(321:1221, 2)));
i want to only change the second column in data to be absorbance= data(:, 2)/(max(data(321:1221, 2)));
but keep the first column the same and then do the part that you had initially.

Accedi per commentare.


the cyclist
the cyclist il 22 Mar 2023
% 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)
a520 = 269.6571
  4 Commenti
the cyclist
the cyclist il 22 Mar 2023
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
Chelsie Boodoo
Chelsie Boodoo il 22 Mar 2023
I misspoke in my first question. The wavelength is the first column, absorbance the second column. id like to replace the absorbance with the normalized absorbance in data to then calculate what you had initially answered.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by