??? Error using ==> horzcat, CAT arguments dimensions are not consistent.
조회 수: 2 (최근 30일)
이전 댓글 표시
I have two cell arrays, both of length n. One array contains nX1 strings, while the other array is contains nx1 type double. I'm trying to create a new variable that is nx2.
The error doesn't seem to make sense to me, since the dimensions of both arrays are identical. This is probably a novice error, so I'll lay out exactly what I've done:
A = {a, b, c, d, ..., n}
B = {1,2,3,4....n}
C = [A,B]
??? Error
If I attempt this:
C = [A;B]
The new variable that is created is (n+1)x1 containing all of the cells in A plus a new cell with text (nx1 double), but lacking any of the values stored within B.
A and B are variables that have been imported using xlsread
If anyone can help me with the problem and shed some light on why exactly this is happening I would greatly appreciate it. Thank you.
댓글 수: 0
답변 (1개)
Thomas
2012년 3월 30일
you should try
A = {'a', 'b', 'c', 'd'}
B={1,2,3,4}
C=[A,B];
D=[A;B];
Make sure A and B are being declared as cells.
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!