0

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

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
  • 1
    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. – Edmund Jul 23 '16 at 12:32

1 Answers1

3

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

Young
  • 7,495
  • 1
  • 20
  • 45
  • 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.

    – Maarten Mennes Jul 25 '16 at 08:33
  • 1
    Great, thanks! Sorry didn't know how to do that, but did it just now! – Maarten Mennes Jul 26 '16 at 14:13