rand(‘state’,0) %表示一个状态,0,1,2…类似表示下标标记, 不同标记则随机值不同,但是相同标记随机值相同
>> rand('state',0);rand(3,1)
>> rand(‘state’,1);rand(3,1)
>> rand(3,1) 以上有何区别?
x=rand(1,5) %产生(0,1)均匀分布的随机数
》x(3) 》x([1 2 5]) 》x(1:3) 》x(3:end)
》x(3:-1:1)
》x(find(x>0.5)) %由大于0.5的元素构成的数组
>> rand('state',0);rand(3,1)
ans =
0.9501
0.2311
0.6068
>> rand('state',1);rand(3,1)
ans =
0.9528
0.7041
0.9539
>> rand(3,1)
ans =
0.5982
0.8407
0.4428
>> x=rand(1,5)
x =
0.8368 0.5187 0.0222 0.3759 0.8986
>> x(3)
ans =
0.0222
>> x([1 2 5])
ans =
0.8368 0.5187 0.8986
>> x(1:3)
ans =
0.8368 0.5187 0.0222
>> x(3:end)
ans =
0.0222 0.3759 0.8986
>> x(3:-1:1)
ans =
0.0222 0.5187 0.8368
>> x(find(x>0.5))
ans =
0.8368 0.5187 0.8986
>>
•
单元结构:
cell
•
把不同属性的数据纳入一个变量中
•
类似于具有下标的矩阵和多维数组,但这些下标不是用圆括号,而是用大括号括起来的。
•
pp=cellstr({'asd' 'testetet' 'sfsdfsdfdfgsdgsg' 'sfdfgfdfgf'})
•
显示内容:
pp(1)
和
pp{1}
的区别
•
清空一个单元数据:
pp(3)=[]
和
pp{3}=[]
的区别
pp=cellstr({'asd' 'testetet' 'sfsdfsdfdfgsdgsg' 'sfdfgfdfgf'})
pp(1) %ans =
'asd'
pp{1}%ans =
asd
pp{3}=[]
% pp =
'asd' 'testetet' [] 'sfdfgfdfgf'
pp{3}={}
%pp =
'asd' 'testetet' {} 'sfdfgfdfgf'