Re: [問題]方程式累加

看板MATLAB作者 (Bubu)時間14年前 (2011/11/22 05:00), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串3/3 (看更多)
※ 引述《s907330204 (Bubu)》之銘言: : ※ 引述《s907330204 (Bubu)》之銘言: : : 我是要解一個數值積分問題 : : 但是方程式很多項不知道怎麼設 : : 我想到如下 但是是行不通的 : : for i=1:1000 : : y(i)=@(x) besselh(i,1,x); : : end : : y=sum(y); : : quad(y,0,pi/2); : : 問一下板上大大 : : 假如方程式很多項 要累加在一起要怎麼設計 : 我在寫清楚點好了 : y=@(x) besselh(1,1,x)+besselh(2,1,x)+besselh(3,1,x)+...+besselh(1000,1,x); : 要怎麼設計 : 謝謝各位大大 真正方程式是這樣 除了x以外,其他符號是已知數 Beta_Jl=@(x) exp(i*k*p_Jl*cos(x-Phi_Jl)); Beta_LI=@(x) exp(i*k*p_LI*cos(x-Phi_LI)); p %--這裡方程式 SUM besselh(p,1,k*(p_lL))*exp(-i*p*(Phi_lL-x-(pi/2)))-- -p Alpha_lL=@(x) ... besselh(-16,1,k*(p_lL))*exp(-i*-16*(Phi_lL-x-(pi/2)))+... besselh(-15,1,k*(p_lL))*exp(-i*-15*(Phi_lL-x-(pi/2)))+... besselh(-14,1,k*(p_lL))*exp(-i*-14*(Phi_lL-x-(pi/2)))+... besselh(-13,1,k*(p_lL))*exp(-i*-13*(Phi_lL-x-(pi/2)))+... besselh(-12,1,k*(p_lL))*exp(-i*-12*(Phi_lL-x-(pi/2)))+... besselh(-11,1,k*(p_lL))*exp(-i*-11*(Phi_lL-x-(pi/2)))+... besselh(-10,1,k*(p_lL))*exp(-i*-10*(Phi_lL-x-(pi/2)))+... besselh(-9,1,k*(p_lL))*exp(-i*-9*(Phi_lL-x-(pi/2)))+... besselh(-8,1,k*(p_lL))*exp(-i*-8*(Phi_lL-x-(pi/2)))+... besselh(-7,1,k*(p_lL))*exp(-i*-7*(Phi_lL-x-(pi/2)))+... besselh(-6,1,k*(p_lL))*exp(-i*-6*(Phi_lL-x-(pi/2)))+... besselh(-5,1,k*(p_lL))*exp(-i*-5*(Phi_lL-x-(pi/2)))+... besselh(-4,1,k*(p_lL))*exp(-i*-4*(Phi_lL-x-(pi/2)))+... besselh(-3,1,k*(p_lL))*exp(-i*-3*(Phi_lL-x-(pi/2)))+... besselh(-2,1,k*(p_lL))*exp(-i*-2*(Phi_lL-x-(pi/2)))+... besselh(-1,1,k*(p_lL))*exp(-i*-1*(Phi_lL-x-(pi/2)))+... besselh(0,1,k*(p_lL))*exp(-i*0*(Phi_lL-x-(pi/2)))+... besselh(1,1,k*(p_lL))*exp(-i*1*(Phi_lL-x-(pi/2)))+... besselh(2,1,k*(p_lL))*exp(-i*2*(Phi_lL-x-(pi/2)))+... besselh(3,1,k*(p_lL))*exp(-i*3*(Phi_lL-x-(pi/2)))+... besselh(4,1,k*(p_lL))*exp(-i*4*(Phi_lL-x-(pi/2)))+... besselh(5,1,k*(p_lL))*exp(-i*5*(Phi_lL-x-(pi/2)))+... besselh(6,1,k*(p_lL))*exp(-i*6*(Phi_lL-x-(pi/2)))+... besselh(7,1,k*(p_lL))*exp(-i*7*(Phi_lL-x-(pi/2)))+... besselh(8,1,k*(p_lL))*exp(-i*8*(Phi_lL-x-(pi/2)))+... besselh(16,1,k*(p_lL))*exp(-i*16*(Phi_lL-x-(pi/2)))+... besselh(15,1,k*(p_lL))*exp(-i*15*(Phi_lL-x-(pi/2)))+... besselh(14,1,k*(p_lL))*exp(-i*14*(Phi_lL-x-(pi/2)))+... besselh(13,1,k*(p_lL))*exp(-i*13*(Phi_lL-x-(pi/2)))+... besselh(12,1,k*(p_lL))*exp(-i*12*(Phi_lL-x-(pi/2)))+... besselh(11,1,k*(p_lL))*exp(-i*11*(Phi_lL-x-(pi/2)))+... besselh(10,1,k*(p_lL))*exp(-i*10*(Phi_lL-x-(pi/2)))+... besselh(9,1,k*(p_lL))*exp(-i*9*(Phi_lL-x-(pi/2))); %----------------------------------------------------------------- f=@(x) 1/(2*pi).*(Beta_Jl(x).*Alpha_lL(x).*Beta_LI(x)); H_besselh=quad(f,0,2*pi) 以上p不等於16,應該大於16,那是我硬幹的寫法 所以想說,各位高手,有沒有設計方法可以解決很多項累加問題 謝謝各位大大。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.34.20.7

11/22 07:14, , 1F
你要不要先積完再sum,可能會好一點
11/22 07:14, 1F

11/22 11:49, , 2F
解決了,謝謝S大
11/22 11:49, 2F
文章代碼(AID): #1Eohllm1 (MATLAB)
討論串 (同標題文章)
文章代碼(AID): #1Eohllm1 (MATLAB)