1. Handling multi-way data in MATLAB

1. Handling multi-way data in MATLAB


  1. Load data
  2. Plot data
  3. Manage data
  4. Summary

Data used
claus.mat contains fluorescence excitation emission data from five samples containing tryptophan, phenylalanine, and tyrosine. 

Learning about the Multi-way Toolbox for MATLAB and about how to view, arrange, and plot multi-way data in MATLAB.

1. Load data

Use load claus and find out what the file contains (use whos).

2. Plot data

Use the plot functions to view data and learn about the three-way structure of the data and how to access it in MATLAB. If you are low on (computer!) memory go to step three initially. Do the following plots and understand what is shown in the plots! Type help subplot to learn of the function subplot.

Plotting Emission spectra 
subplot(2,1,2),plot([X(:,:,1) X(:,:,2)]')

What’s the difference between the two plots?

Plotting excitation spectra 
Try to plot some excitation spectra as 


This does not work! The reason is that X(:,1,:) is not a matrix. Use the command size to figure out what X(:,1,:)is (Tell me)? With the command plot, we can only plot matrices so we have modify things a bit


What’s on the plots. What’s the difference between the two plots?

If we want to be fancy we can add correct axes and titles to the plots. In the vector ExAx (type whos to see the data available), the actual 61 excitation wavelengths are given.
We can add these to the plots by


And we can add more by typing

title('Fluorescence excitation spectra',


Plotting landscapes

All the following commands will plot all the data from sample number 2. Try to understand the differences in the plots. That is important when you want to visualize your own data. Use MATLAB help for functions you don’t understand.

axis tight

All plots show the same data. What’s the difference?

3. Manage data

As an example of managing the data, reduce the size of for easier computations. Use only every third wavelength in the excitation mode (mode three) and every sixth wavelength in the emission mode (mode two). An easy way to do that  is the following

Xnew = X(:,1:6:end,1:3:end);

If you have very little memory reduce the data even more. Remember to reduce EmAx and ExAx accordingly if you plan to use those for plotting. 

4. Summary

In this chapter it has been shown how to manipulate and plot the data.