Matrix reshape from 3d to 2d

3 views (last 30 days)
Boby S
Boby S on 13 May 2020
Commented: Boby S on 15 May 2020
Hi
I have 3d matrix (1*80). Each cell has diffrent rows with 4 column. I want to convert all of it to 2d matrix but I want to keep the 3d matrix dimension(column,1-80) as index for my data.
So, I need t to add a new column(3d dimension) to my new 2d matrix as 5th column.
  2 Comments
Boby S
Boby S on 15 May 2020
yes, they are not same size. The final size will be(sum of rows,5)

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 13 May 2020
Output = cell2mat(arrayfun(@(IDX) [YourMatrix{IDX}, repmat(IDX, size(YourMatrix{IDX},1), 1)], (1:length(YourMatrix)).', 'uniform', 0));

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!