2017-05-21 11 views
0

내가 { 'foo는' '바'}에 [1 2.2]을 추가하고 얻으려고 :추가] NX 1 벡터 NX 1 세포 배열

'foo' 'ba'    
    1  2.200000 

를 내가 거의 다 해요 :

>> A = {'foo' 'ba'} 

A = 

    1×2 cell array 

    'foo' 'ba' 

>> b = [1 2.2] 

b = 

    1.000000000000000 2.200000000000000 

>> [A;b] 
Error using vertcat 
Dimensions of matrices being concatenated are 
not consistent. 

>> [A;num2cell(b)] 

ans = 

    2×2 cell array 

    'foo' 'ba'    
    [ 1] [2.200000000000000] 

[]를 제거하는 방법?

+1

제대로하고 있습니다. Matlab에서'1'과'[1]'은 정확히 똑같습니다 ('isequal (1, [1]) '로 확인하십시오) –

답변

0

[A;num2cell(b)]은 올바른 구현입니다.

당신은

[A(1);b(1)] 

ans = 

    'foo' 
    [ 1] 

주의 일을 시도 할 수 있습니다로 표현 벡터 B 요소 (1) [1] 대한 equalivalent있는.

0
A = {'foo' 'ba'} ; 
b = {'1' '2.2'} ; 
[A ;b] 

or 

vertcat(A,b)