0
$\begingroup$

I am new to Mathematica, so this might be a very basic question; however, I cannot find a solution to this and it is taking me very long.

For my research I am probing the photoluminescence response of a organic film with and without an external magnetic field, and also take a background measurement with and without the field. This generates large data files, with equal x values (wavelengths) and different y values (intensity) with dimensions {3648, 2}. I would like to ListPlot the difference between the data, but when I do something like this:

Signal = WithMagnet - WithoutMagnet

I end up with a vertical line at x=0.

Can anyone here help me how to plot the difference in y-values while keeping the x-axis the same as in the individual files?

Hope someone can help me with this! Cheers

$\endgroup$
  • 1
    $\begingroup$ Post a link to the data (or a portion of the data here in readable/copy-paste format) and the code you have been using to plot. $\endgroup$ – Edmund Jul 23 '16 at 12:32
3
$\begingroup$

Use Part to subtract intensity and Transpose to align with the wavelength data:

wavelength = Range[350, 750, (400/3647)];

withMagnet = Transpose[{wavelength, RandomReal[1, 3648]}];
withoutMagnet = Transpose[{wavelength, RandomReal[1, 3648]}];

(*The above code just simulates your imported data*)

diff = Transpose[{withoutMagnet[[All, 1]], 
                  withMagnet[[All, 2]] - withoutMagnet[[All, 2]]}];

ListLinePlot[diff, PlotRange -> All, Mesh -> All]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks for the answer. You transpose twice, I do not have to do that right? I now do the following: 'Analyse = Transpose[{without1[[All, 1]], with1[[All, 2]] - without1[[All, 2]]}]; ListPlot[Aanalyse, PlotRange -> All, PlotLabel -> Emission, AxesLabel -> {wavelength, arbitrary units}, LabelStyle -> Directive[Bold, Orange]]' That should give me the correct graph right? As the photoluminescence should be stronger for this film and it has not been showing me good results, I do not really know what to expect from the data, but it looks correct. $\endgroup$ – Maarten Mennes Jul 25 '16 at 8:33
  • 1
    $\begingroup$ Great, thanks! Sorry didn't know how to do that, but did it just now! $\endgroup$ – Maarten Mennes Jul 26 '16 at 14:13

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.