06.08.2013 Views

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

【例 2.12.1-2】非数元素的寻访<br />

rand('state',0)<br />

R=rand(2,5);R(1,5)=NaN;R(2,3)=NaN<br />

R =<br />

0.9501 0.6068 0.8913 0.4565 NaN<br />

0.2311 0.4860 NaN 0.0185 0.4447<br />

isnan(R)<br />

ans =<br />

0 0 0 0 1<br />

0 0 1 0 0<br />

Linear_index=find(isnan(R))<br />

[r_index,c_index]=ind2sub(size(R),Linear_index);<br />

disp('r_index c_index'),disp([r_index c_index])<br />

Linear_index =<br />

6<br />

9<br />

r_index c_index<br />

2 3<br />

1 5<br />

2.12.2 “空”数组<br />

【例 2.12.2-1】关于“空”数组的算例。<br />

(1)<br />

a=[],b=ones(2,0),c=zeros(2,0),d=eye(2,0),f=rand(2,3,0,4)<br />

a =<br />

[]<br />

b =<br />

Empty matrix: 2-by-0<br />

c =<br />

Empty matrix: 2-by-0<br />

d =<br />

Empty matrix: 2-by-0<br />

f =<br />

Empty array: 2-by-3-by-0-by-4<br />

(2)<br />

class(a)<br />

isnumeric(a)<br />

isempty(a)<br />

ans =<br />

double<br />

ans =<br />

1<br />

ans =<br />

1<br />

which a<br />

ndims(a)<br />

size(a)<br />

a is a variable.<br />

ans =<br />

2<br />

ans =<br />

0 0<br />

17

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!