quad function

4 次查看(过去 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