作者kobenein (哈哈哈)
看板MATLAB
标题Re: [问题]for回圈中 加入if判断式 想把值取出来
时间Thu Nov 6 19:58:28 2014
method 1
a=[1 2 3;4 5 6;7 8 9];
k=0;
for i=1:3;
for j=1:3;
a(i,j)
if a(i,j)>5
k=k+1;
b(k)=a(i,j);
end
end
end
method 2
b=a(a>5);
--
-好管弦事-
A place about cello and music....
http://fnt72.blogspot.com/
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 59.124.1.1
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MATLAB/M.1415275111.A.3F3.html
※ 编辑: kobenein (59.124.1.1), 11/06/2014 19:58:59