精華區beta MATLAB 關於我們 聯絡資訊
※ 引述《iHateFourier (fourier...)》之銘言: : 我想要請教一個問題, : 如果要產生 NxN 矩陣 A : for i=1:1:N : for j=1:1:N : A(i,j)=i+j; : end : end : 就是A裡面的每個element 都要用 這個element得index做運算, : 步知道是不是有方法可以不用 用到兩個迴圈, : MATLAB是不是有提供更簡潔的方法,謝謝。 [ x y ] = meshgrid( [ 1 : N ] , [ 1 : N ] ) ; A = x + y -- 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: 61.225.205.208
iHateFourier:謝謝 ^^ 01/17 23:06
zupo:推.太方便了 01/19 12:26