2013-07-27 158 views
0

我創建了一個細胞與MATLAB單元陣列操作

s = cell(4,4); 

現在我想編輯兩個條目:

s{1,1:2} = ?? //what do I write here? 

我已經試過了以下幾件事: Š{1,1:2 } = {A,B}; s {1,1:2} = {A; B}; s {1,1:2} = {{A},{B}}; 但他們都沒有工作。

它總是說:'這個任務的右手邊的數值太少,無法滿足左手邊。

我該怎麼做?

在此先感謝!

回答

0

使用

s(1,1:2) = {A,B}; 

例子:

>> s(1,1:3) = {'first','second','third'} 

s = 

    'first' 'second' 'third'  [] 
     []   []   []  [] 
     []   []   []  [] 
     []   []   []  [] 


>> A=12 

A = 

    12 

>> B=4 

B = 

    4 

>> s(1,1:2) = {A,B} 

s = 

    [12] [4] 'third'  [] 
     []  []   []  [] 
     []  []   []  [] 
     []  []   []  []