Error when calling parameterized function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
raymond bryant
il 23 Mar 2020
Risposto: Star Strider
il 24 Mar 2020
Here is my main body code:
d = .0127;
a = .00635;
x = d/a;
val = scalingfunction(x)
Here is my function code:
function [val] = scalingfunction(x)
fun = @(x,y) ((1/(y^2+1)^(3/2))-(1/((y+x)^2 + 1))^(3/2))^2;
val = integral(@(y) fun(x,y),-Inf,Inf);
end
Here is my error:
val = integral(@(y) fun(x,y),-Inf,Inf);
Error in electro_magnetic_model (line 4)
val = scalingfunction(x);
0 Commenti
Risposta accettata
Star Strider
il 24 Mar 2020
Use element-wise operations:
function [val] = scalingfunction(x)
fun = @(x,y) ((1./(y.^2+1).^(3/2))-(1./((y+x).^2 + 1)).^(3/2)).^2;
val = integral(@(y) fun(x,y),-Inf,Inf);
end
that then produces:
val =
1.700680101619312
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Quantum Mechanics in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!