I have a 1x5 cell each containing 4000 points of data. The 4000 points of data fill the columns, Id like to have each 1x4000 turn into a 4000x1. How to do this? Easy question right?
Thanks in advance!

 채택된 답변

Guillaume
Guillaume 2018년 9월 20일

0 개 추천

cellfun(@tranpose, yourcellarray, 'UniformOutput', false)
However, there's little point in using a cell array if all your vectors are the same size, so you would be better off transforming that into a 2-d matrix, so:
[yourcellarray{:}] %for a 4000x5 matrix
[yourcellarray{:}].' %for a 5x4000 matrix

댓글 수: 4

Error using cellfun Input #3 expected to be a cell array, was char instead.
I got this error. What could that be?
When I do just the [yourcellarray{:}] it turns it into a 1x16000 cell. I feel like we are close.
Actually, it worked. I do not know what I did the first time. Thank you!
Error using cellfun Input #3 expected to be a cell array, was char instead.
You must have misspelled 'UniformOutput'
it turns it into a 1x16000
My mistake. The code I wrote is for column vectors, not row vectors. With row vectors:
vertcat(yourcellarray{:}) %for a 5x4000 matrix
vertcat(yourcellarray{:}).' %for a 4000x5 matrix

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2018년 9월 20일

0 개 추천

A{1} = rand(5,1) ;
A{2} = rand(5,1) ;
A{3} = rand(5,1) ;
A{4} = rand(5,1) ;
B = cellfun(@(x) x',A,'un',0)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2016b

질문:

2018년 9월 20일

댓글:

2018년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by