On using Trapz for a function defined by a variable using syms
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alvin
am 19 Jul. 2017
Kommentiert: Alvin
am 19 Jul. 2017
clear
g = 1;
k = 0.2;
no = 0;
nm = 0;
D = 1;
O = -1;
gam = 0.2;
syms w
xa = -1i.*(w+D)+(k./2);
xb = -1i.*(w-O)+ (gam./2);
xac = conj(xa);
xbc = conj(xb);
c = (1i.*g.*sqrt(k))./(xa.*xb + g.^2);
d = (xa.*sqrt(gam))./(xa.*xb + g.^2);
f(w) = (abs(c).^2).*(no+(1/2))+(abs(d).^2).*(nm+(1/2));
df = diff(f,w);
R = -999:999;
%Q = trapz(R,f(w));
fplot(f(w))
set(gca,'FontSize',14)
title('g = 1, \Delta = 1')
xlabel('\omega')
ylabel('S_{bb}')
Greetings!
I am trying to find the area under a power spectrum. All seems to be well when it comes to plotting it, however as I try to use the Trapz() function, it is giving me the error: Input arguments must be convertible to floating-point numbers. Now I have tried searching for a solution online for a while but I still couldn't solve it. Would appreciate any help possible!
Thank you very much in advance!
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!