Prev: GA code
Next: Restructuring cell arrays with cellfun
From: Jarodd Holmes on 6 Aug 2010 21:16 Dear fellow Matlab users, I am trying to solve the following problem: I have a cell array with 500 cells, each cells contains 4 arrays with information (it is basically a cell array and each cell contains a matrix with four columns (column 1, column 2, column 3 and column 4) and 100 lines). I want to use cellfun and make matlab go into each cell and reorder the column order, so that the new cell array has the same number of cells and the same matrix, except that the order of the columns should be (column 1, column 3, column 2, column 4). If I didn't have a cell array and only one matrix X, i would just use this command: newX = [x(:,1) x(:,3) x(:,2) x(:,4)]. However with a cell array I cannot seem to make the proper usage of the cellfun command. I tried this one: newreturns=cellfun(@(x) [x(:,1) x(:,3) x(:,2) x(:,4)],returns, 'uni',false) but it does not work... could you please tell me where is my mistake? I just don't know how to define "all cells" and I am sure that the mistake is after the @(x) part, but I don't know how to fix it. All input greatly appreciated! Best Regards!
|
Pages: 1 Prev: GA code Next: Restructuring cell arrays with cellfun |