Re: [問題] 矩陣的問題....已回收

看板MATLAB作者 (神無月 孝臣)時間17年前 (2008/11/25 15:05), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《kakar0to (Moonlight Shadow)》之銘言: : 有沒有只用矩陣的方法(不要用for迴圈) : 做出 a = [1 -1 1 -1]這種矩陣... : 因為我目前只想到用for迴圈 一個一個去給值 : 所以想來問問看有沒有更快的方式...謝謝... 你的問題有點不清楚 不太能完全確定你的需求 但如果只是要正負1相間排列的話 只要這樣子寫就可以了 n = 2 ; a = reshape( [ ones( 1 , n ) ; - ones( 1 , n ) ] , 1 , [] ) 如果裡面還有其他需求的話再說 -- Deserves death! I daresay he does. Many that live deserve death. And some die that deserve life. Can you give that to them? Then be not too eager to deal out death in the name of justice, fearing for your own safty. Even the wise cannot see all ends. Gandalf to Frodo -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.120.25.235

11/25 15:10, , 1F
感謝大大 是我要的需求^^
11/25 15:10, 1F
文章代碼(AID): #19AwF1yv (MATLAB)
討論串 (同標題文章)
文章代碼(AID): #19AwF1yv (MATLAB)