Double integration using dblquad not working
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
what is the mistake in this code, I'm getting this error "Error using dblquad>innerintegral (line 76)
Inputs must be floats, namely single or double."
SNRdB = 1;
SNR=10.^(SNRdB./10);
sigma=1./SNR;
sigma_1=(sqrt(3./4)).*sigma;
sigma_2=(sqrt(1./4)).*sigma;
syms mu_x sigma_x s dot_s
f_x=(1./(2*pi*(sigma_x).^2)).*exp(-(s-mu_x).^2./(2.*(sigma_x).^2))
f_s_1=subs(f_x,[mu_x,sigma_x],[dot_s,sigma_1])
f_dot_s=subs(f_x, [mu_x,sigma_x],[0,1]);
Pr=erf(s./(s.*sigma_2))*f_s_1*f_dot_s
Fun=@(x,y)subs(Pr,[s,dot_s],[x,y])
Pr_pos_c = dblquad(@(x,y)Fun(x,y),-inf,inf,0,inf)
0 Commenti
Risposte (1)
Steven Lord
il 14 Giu 2019
The function you pass into dblquad must return a double or single value. It cannot return a sym object. To compute a double integral using sym objects, call int twice. Alternately if you want to use dblquad (or the integral2 function, which is the recommended replacement for dblquad) convert your symbolic expression into a function handle using matlabFunction or call double on the results of the subs call inside your Fun function.
Fun=@(x,y)double(subs(Pr,[s,dot_s],[x,y]))
3 Commenti
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!