2011-06-28 7 views

答えて

2

を分離する方法はありますソリューション:

v = [0345;0230;0540;2340]; 
vv = num2str(v,'%04d'); %# convert to strings, 4 digits, fill with zeros 
v1 = str2num(vv(:,1:2)) %# extract first two digits, convert back to number 
v2 = str2num(vv(:,3:4)) %# extract last two digits, convert back to number 

結果:もちろん

v1 = 
    3 
    2 
    5 
    23 
v2 = 
    45 
    30 
    40 
    40 

、文字列のセルアレイ(先頭の0を持つが保たれ)として、あなたが結果をしたい場合は、以下を使用します。

>> v1 = cellstr(num2str(v1,'%02d')) 
v1 = 
    '03' 
    '02' 
    '05' 
    '23' 
3

どの程度

vector=[0345;0230;0540;2340]; 
v1 = mod(vector,100) 
(vector-v1)/100 
関連する問題