How to combine and transpose arrays?

조회 수: 6 (최근 30일)
Michael Seed
Michael Seed 2021년 9월 17일
댓글: Michael Seed 2021년 9월 17일
I have 4 arrays. Each one is 39690x1 double. I need to combine them into one array that is 4x39690 double.
inp = cat(2,He,Lu);
inp = inp';
This works when I combine two arrays.
imp = cat(4,S1,S2,S3,S4);
inp = inp';
But when I try it on 4 arrays it gives me errors: Error using '
TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to
transpose pages or PERMUTE to reorder dimensions of N-D arrays.
I tried out permute but can only find examples on how to use it on 3D images or excel files, it doesn't do what I need. And I can't find much at all on how to use PAGETRANSPOSE.

답변 (1개)

Chunru
Chunru 2021년 9월 17일
편집: Chunru 2021년 9월 17일
s1 = rand(5,1);
s2 = rand(5,1);
s3 = rand(5,1);
s4 = rand(5,1);
imp =[s1 s2 s3 s4]'
imp = 4×5
0.3756 0.1015 0.8919 0.9454 0.0621 0.3403 0.5383 0.9285 0.7061 0.5837 0.2148 0.9999 0.9353 0.5535 0.0733 0.8793 0.8986 0.4176 0.2299 0.1544
% or
imp1 = cat(2, s1, s2, s3, s4)' % 2 along dim 2
imp1 = 4×5
0.3756 0.1015 0.8919 0.9454 0.0621 0.3403 0.5383 0.9285 0.7061 0.5837 0.2148 0.9999 0.9353 0.5535 0.0733 0.8793 0.8986 0.4176 0.2299 0.1544

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by