필터 지우기
필터 지우기

quad function

조회 수: 1 (최근 30일)
Sudipta Basu
Sudipta Basu 2012년 3월 13일
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.

채택된 답변

Andrei Bobrov
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
Sudipta Basu
Sudipta Basu 2012년 3월 13일
I have another query to this...Is it not possible that I will get a result in terms of T. I mean if I enter out=f1(T), it will given an expression in terms of T.
Alexander
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개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by