2
$\begingroup$

I currently have a table of absorbances vs. wavenumbers. How would I change that to a table of %transmittances vs. wavenumbers? The relationship is given by

%Transmittance = (10^(-absorbance))*100] 

I've tried:

newtable = Replace[currenttable, i -> ((10^(-i))*100)] 

No errors occur, but nothing happens.

$\endgroup$
  • 2
    $\begingroup$ You may use newtable = currenttable; newtable[[All, i]] = (10^(-newtable[[All, i]]))*100; where i is the number of the column. If you wonder what [[ ]] is, look up Part in the documentation. $\endgroup$ – Henrik Schumacher Apr 9 at 5:53
  • 2
    $\begingroup$ Is the table structured as a list of pairs in form {wave-number, absorbance}? $\endgroup$ – m_goldberg Apr 9 at 5:54
  • 3
    $\begingroup$ If you could show a brief excerpt of your table in your question, it would be easier to help you more effectively. $\endgroup$ – MarcoB Apr 9 at 5:59
4
$\begingroup$

Contrived data based on the element form {wave-number, absorbance}.

SeedRandom[42]; 
With[{n = 5}, data = Sort @ Transpose[{RandomInteger[100, n], RandomReal[1., n]}]]
{{4, 0.142803}, {6, 0.628702}, {15, 0.290081}, {54, 0.0292846}, {66, 0.105067}}

Assuming you want to keep the original data and not destructively change the 2nd column in it, you could proceed as follows:

newdata = data;
newdata[[All, 2]] = 100 10^-data[[All, 2]];
newdata
{{4, 71.9776}, {6, 23.5124}, {15, 51.2765}, {54, 93.4793}, {66, 78.5114}}

This works because all Mathematica's arithmetic operators have a property called Listable, which means they automatically map over lists such as data[[All, 2]]. In this case the operator doing the mapping is Power.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.