Multiple errors with an integral
Afficher commentaires plus anciens
I am trying to find the energy of a signal in the frequency domain, but I am having trouble with the integral. I have had multiple errors which is why I did not choose one for the title. Some are: "Undefined function 'abs' for input arguments of type 'function_handle'", Error using integralCalc (...)set the 'ArrayValued' option to true..",etc.
This is the code:
clc
Fs=33280;
t = 0:1/Fs:(N/Fs)-(1/Fs);
N = 256;
x = 4*sin(1040*pi*t) + cos(3120*pi*t);
w = (-2*pi*Fs)/2:(2*pi*Fs)/N:(2*pi*Fs)/2-(2*pi*Fs)/N;
X =@(w) 1/N*fftshift(fft(x));
Px = integral((abs(X)).^2,-inf,inf);
disp(Px)
The error says: Undefined function 'abs' for input arguments of type 'function_handle'.
x is the signal in time, and X is the signal in the domain of frequency after Fourier.
Réponse acceptée
Plus de réponses (1)
nassima el ouarie
le 6 Jan 2022
0 votes
please help me why the integration function is not working i don't know why ??
i want to compute this integral but this is what ti gives me matlab :
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in JENERALANDA (line 12)
JG1=integral(f,L1,L2);
this is the function i wrote to compute the integral :
function [JGL] = JENERALANDA()
syms L;
q=1.602176620*10^(-19);
Lw=(90*10^(-9));
w=(900*10^(-9));
N=50;
B=changalphaB();
Z=changalphaW();
L1=(0.24*10^(-6));
L2=(1.08*10^(-6));
f=@(L) ((2.3*10^(18)).*(1-exp(-B.*w-Z.*N.*Lw)));
JG1=integral(f,L1,L2);
JGL=-(q.*(JG1));
end
1 commentaire
Walter Roberson
le 6 Jan 2022
f=@(L) ((2.3*10^(18)).*(1-exp(-B.*w-Z.*N.*Lw)));
That does not use L, so no matter what the input it always returns the same output.
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!