作者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/m.aspx?n=bbs/MATLAB/M.1415275111.A.3F3.html
※ 編輯: kobenein (59.124.1.1), 11/06/2014 19:58:59