|
"james bejon" <jamesbejon@yahoo.co.uk> wrote in message
news:hnp1a9$sqh$1@fred.mathworks.com...
> Thanks. I'm still struggling a bit with this though. Suppose I've
> imported some text data from an Excel spreadsheet. It's come in as, say,
> a 20 x 10 cell. Now, how do I copy, say, the 5th column to the 4th
> column, or everything from the 3rd cell down in the 5th column to their
> equivalents in the 4th column? I'm obviously not understanding the syntax
> here.
Indexing into a cell array with parentheses () operates on the cells in the
cell array.
Indexing into a cell array with curly braces {} operates on _the contents
of_ the cells in the cell array.
C = cell(5, 3);% using a smaller example for demonstration
for k = 1:numel(C)
C{k} = k; % Since this uses {}, we're assigning to the _contents_ of the
kth cell
C(k) = {k}; % or we can assign a cell as the kth cell using ()
end
C % Just for display purposes
C(:, 2) = C(:, 3) % copying the CELLS from the 3rd column into the CELLS in
the 2nd column
% or
[C{:, 1}] = C{:, 3} % copy the _contents_ of the cells from the 3rd column
into the _contents_ of the cells in the 1st column
The latter example may take you a little bit of time to understand, and I
think we only made it work without DEAL a few (4 or 5) releases ago. For an
explanation, look at the following page from the documentation that talks
about comma-separated lists:
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/br2js35-1.html
--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|