quad function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Andrei Bobrov
le 13 Mar 2012
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 commentaires
Alexander
le 14 Mar 2012
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Special Values dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!