Re: [問題] for loop可以指定變數值嗎?已回收

看板MATLAB作者 (神無月 孝臣)時間16年前 (2010/07/22 23:07), 編輯推噓2(200)
留言2則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《freezein (....)》之銘言: : 之前用for loop總是會寫 : for i=1:1:13 : ........ : end : 請問如果想要設定i=30, 47, 63... : 請問loop要怎麼寫呢? : 感激不盡! 如果沒有規律的話 可以先把要用的數字用矩陣存好 像是A = [ 30 47 63 ] 然後要用的時候再用index去叫出來用 像這樣 for i = 1 : 3 A( i ) end -- A Man or a Parasite What is the difference between a man and a parasite? A man builds. A parasite asks "Where is my share?" A man creates. A parasite says, "What will the neighbors think?" A man invents. A parasite says, "Watch out, or you might tread on the toes of God..." ─Andrew Ryan -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.225.205.65

07/22 23:14, , 1F
感謝!
07/22 23:14, 1F

07/23 00:23, , 2F
直接用 for i=A 即可
07/23 00:23, 2F
文章代碼(AID): #1CI5wn25 (MATLAB)
文章代碼(AID): #1CI5wn25 (MATLAB)