quad function
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I am having difficulty using quad function as I am using it for the first time. I have a function, i (t) = 8e^-t/T sin(2*pi*t/T) for 0 ≤ t ≤ T/2 i (t) = 0 for T/2 ≤ t ≤ T I want to integrate it using quad function in MATLAB. I have written the following code syms T i= @(x)(8.*exp(-x/T).*sin((2*pi).*x/T))^2 Irms = ((quad(i,0,T/2) )^0.5)/T
But, MATLAB is giving the error ??? Error using ==> mupadmex Error in MuPAD command: not a square matrix [(Dom::Matrix(Dom::ExpressionField()))::_power]
Error in ==> sym.sym>sym.mpower at 198 B = mupadmex('mllib::mpower',A.s,p.s);
Error in ==> @(x)(8.*exp(-x/T).*sin((2*pi).*x/T))^2
Error in ==> quad at 77 y = f(x, varargin{:});
Can anyone tell me where am I wrong.
댓글 수: 0
채택된 답변
Andrei Bobrov
2012년 3월 13일
i1 = @(t,T)(8*exp(-t/T).* sin(2*pi*t/T)).^2.*(t < T/2)
f1 = @(T)quad(@(t)i1(t,T),0,T/2)
% e.g. T = 10;
out = f1(10)
댓글 수: 2
Alexander
2012년 3월 14일
The function 'quad' returns only doubles. You can use the Symbolic Math Toolbox to get an integral in terms of T:
syms x T
i = (8.*exp(-x/T).*sin((2*pi).*x/T))^2
Irms = ((int(i,0,T/2) )^0.5)/T
This gives:
Irms =
((64*pi^2*T*exp(-1)*(exp(1) - 1))/(4*pi^2 + 1))^(1/2)/T
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Special Values에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!