필터 지우기
필터 지우기

A two dimensional matrix with columns having different length

조회 수: 40 (최근 30일)
Aakash
Aakash 2011년 9월 27일
How can I create a two dimensional matrix having different column length? For example, can I assign two column vectors C1 = {1 2 3 4}' and C2 = {1 2 3 4 5}' to a single matrix C?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 9월 27일
No. You can't. However, you can use cell array.
C1=[1 2 3 4]';
C2=[1 2 3 4 5]';
C={C1,C2};

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 9월 27일
You cannot do that with a numerical array, but you can use cell arrays.
C = {C1, C2};
This will, however, be "two dimensional" only in the degenerate sense that one of the dimensions could be the constant 1. C{2} would be the same as C{1,2} which would be the entire column vector C2. You could use C{2}(3) where you probably would have instead preferred to index as C(3,2) (third row, 2nd column).

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by