看板 MATLAB 關於我們 聯絡資訊
: 推 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
ironmanstock:謝謝 我懂了 小小的一段竟然這麼多功能,我誤解了. 06/07 16:32
ironmanstock:原來可以逐一對矩陣的元素進行比對,這是我從沒看過的 06/07 16:34
ironmanstock:不知哪邊對這種語法有基本的介紹.知道的人可mail我, 06/07 16:35
ironmanstock:真的是很棒的語法!! 受教了1 06/07 16:36