Home → Products → Dagra → Matlab

Using Digitized Graph Data in Matlab

Graphs digitized with Dagra can be loaded into Matlab in three ways. The easiest is with the LoadDagra.m function for Matlab. This function loads Dagra documents into a Matlab structure.

Digitized data can also be copied onto the clipboard (Edit→Copy Data… in Dagra) and pasted into Matlab's command line window or exported into a text file (File→Export Data… in Dagra) and imported using Matlab's dlmread function.

On this page:

Using the LoadDagra.m Matlab function

Setup

LoadDagra.m must be on Matlab's search path before it can be used. The function is installed in the Dagra application directory in the folder Components\Matlab\.

If Dagra was installed in the default location, then the Matlab command to include it in the search path is:

>> addpath('c:\Program Files\Blue Leaf Software\Dagra\Components\Matlab');

Load the data

LoadDagra.m takes a single argument, the path to the Dagra document to load. Only the filename is needed if the file is in the current directory. It returns a structure containing fields for each series in the Dagra document:

>> data = LoadDagra('Bromocresol green.dag')
data =
           Basic: [1x1 struct]
            Acid: [1x1 struct]
    Intermediate: [1x1 struct]
>>

Spaces in the series name are replaced by underscore characters to form valid Matlab fields.

The Series Structure

Each series structure contains two fields: x and y. Each is a vector containing the exported data. These vectors will always be the same length.

>> data.Acid
ans =
    x: [89x1 double]
    y: [89x1 double]
>>

Note: if you are using an expired trial version of Dagra, the exported data contains random noise. Purchase a Dagra license to recover the original high-precision data.

Plotting the Data

This Matlab code creates a plot showing the graphical source image on the left and data digitized with Dagra on the right:

>> figure(1);
>> img = imread('Bromocresol green spectrum.png');
>> subplot(1,2,1);
>> image(img);
>> axis('off');
>> subplot(1,2,2);
>> plot(data.Acid.x, data.Acid.y, 'b', data.Basic.x, data.Basic.y, 'r', data.Intermediate.x, data.Intermediate.y, 'g');
>> xlabel('Wavelength [nm]'); ylabel('Absorption'); grid on;

Data digitized with Dagra and plotted in Matlab

The spectrum of Bromocresol green from Wikipedia (left) and the digitized data plotted in Matlab (right).

Interpolating the Data

Dagra exports sufficient data to accurately reconstruct the curves. So intermediate values can be obtained with linear interpolation using Matlab's interp1 function.

To estimate the absorbance of the acid form of Bromocresol green at 450, 515 and 570 nm, for example:

>> interp1(data.Acid.x, data.Acid.y, [450 515 550])
ans =
      0.29789      0.14131     0.053782
>>

Download LoadDagra.m for Matlab

LoadDagra.m is installed by the Dagra setup file. It can be found in the Components\Matalb folder of the installation directory (normally c:\Program Files\Blue Leaf Software\Dagra). A trial version of Dagra is available here.

You can also download LoadDagra.m here