Solving multiple integrals that include exp

I can't figure out what I'm doing wrong, I keep getting an error message: Error using .* Matrix dimensions must agree.
for e = exp(k.*w.*t);
Here's the code. I just need help debugging.
T = 9; T1 = 0.25; w = 2*pi/T;
e = exp(k.*w.*t);
fun1 = @(t) (1+4*t)*e;
fun2 = @(t) (1-4.*t).*e;
k = 1;
C = (1/9).*(integral(fun1,-T1,0) + integral(fun2,0,T1))
Eventually I will use a for loop to calculate C for different k values.

댓글 수: 1

Walter Roberson
Walter Roberson 2012년 11월 13일
in fun2 you carefully used .* but you forgot to do that in fun1.

댓글을 달려면 로그인하십시오.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 11월 13일
편집: Andrei Bobrov 2012년 11월 13일

0 개 추천

T = 9;
T1 = 0.25;
w = 2*pi/T;
k=1;
fun = @(t,s)(1+4*s*t).*exp(k*w*t);
C = quad(@(t)fun(t,1),-T1,0) + quad(@(t)fun(t,-1),0,T1)
Here I was used MATLAB R2011b.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Execution Speed에 대해 자세히 알아보기

질문:

A P
2012년 11월 13일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by