# Interchanging Columns and Rows in a Matrix Imported from Excel

Discussion in 'MATLAB' started by Stephen Molnar, Jul 23, 2006.

1. ### Stephen MolnarGuest

I am a new user and have what I hope is a trivial problem.

I need to model data from a Raman spectrophotometer. The spectra are
in an Excel spreadsheet of 11 columns and 1784 rows. This results,
of course, in a 1784X11 matrix in MATLAB. Unfortunately, the model
that I am attemping to impliment requires a 11X178a matrix. How do I
accomplish the transformation. Excel doesn't have enough colums to
transpose the matrix before importing to MATLAB.

Alternately, the OMNIC software (spectrometer software) allows me to
save individual spectra as a 2 column by 1784 row ascii file. Is it
possible to import just the second column, the intensity data (the
first column is the frequency shift data and is the same for all of
the spcetra in a set) as a row in the resulting MATLAB matrix and
then add each successive spectrum as the next row in the MATLAB
matrix?

Stephen Molnar, Jul 23, 2006

2. ### FredGuest

Transposing a matrix in matlab is very simple.
Original matrix: A
Transposed matrix: A'

Since you are obviously new to Mablab, try for example the
following code to understand what I mean.

A = rand(2,5)
A = A'

/Fred

Fred, Jul 23, 2006

3. ### Stephen MolnarGuest

Thanks, Fred.

I think that I have just redefined trivial.

Stephen Molnar, Jul 23, 2006