Re: [問題] 有沒誰看過這個語法X(idx==1,1),請指教
: 推 ht15trep:kmeans分為第1類的點取出來並畫紅色點 06/06 22:32
: → ht15trep:== 就是幫你從頭比較到尾了 06/06 22:33
: → ironmanstock:這種是把==加在Matrix內就可以同時比較兩個矩陣嗎? 06/06 22:40
: → ironmanstock:這個語法好怪. 06/06 22:42
這個不是同時比較兩個矩陣
這個只是把許多步驟同時合併在一起寫了
假設idx = [ 1 2 3 1 2 1 3 ]
x = [ 1 2
3 4
5 6
7 8
9 10
11 12
13 14 ]
x( idx == 1 , 1 )是這樣運算的
會先進行idx == 1這個邏輯運算
因此idx == 1會跑出[ 1 0 0 1 0 1 0 ]這個輸出
接著再將這個[ 1 0 0 1 0 1 0 ]放入x內將值取出來
所以是x( [ 1 0 0 1 0 1 0 ] , 1 ) = 1
7
11
如果你覺得這種把很多步驟寫在一起的寫法不容易閱讀的話
你可以自己拆開來改寫變成這樣
a = idx == 1 ;
x( a , 1 )
這樣應該會比較容易閱讀
運算的結果也會一樣
--
On the surface, your parents sought a private life, using their great talents
to provide for you. They learned to twist the lies of church and government,
believing themselves masters of the system. But the parasites say "NO! The
child has a duty! He'll go to war and die for the nation."
─Andrew Ryan
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.120.24.116
推
06/07 16:32, , 1F
06/07 16:32, 1F
→
06/07 16:34, , 2F
06/07 16:34, 2F
→
06/07 16:35, , 3F
06/07 16:35, 3F
→
06/07 16:36, , 4F
06/07 16:36, 4F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):