Warning using integral function: Function behaves unexpectedly on array inputs
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
fplot(@(E) Current(E))
Current(1)
function test_integral = Current(V)
test_integral = integral(@(E) temp(E,V), -inf, inf);
function tempf = temp(E,V)
tempf = V.*exp(-(E.^2));
end
end
This is basically my code. Running this gives an error message of
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and
shape as the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function/FunctionLine/updateFunction
In matlab.graphics.function/FunctionLine/set.Function_I
In matlab.graphics.function/FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 245)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 200)
In fplot>vectorizeFplot (line 200)
In fplot (line 166)
In test4 (line 4)
I think this has something to do with the integral function and fplot function colliding, but I don't know how any of the two functions can be substituted. Perhaps there is a way to vectorize the results of the Current function? Again, I don't know if this is even the right direction.
Help would be very much appreciated. Thanks in advance.
0 commentaires
Réponse acceptée
Dyuman Joshi
le 9 Jan 2024
Modifié(e) : Dyuman Joshi
le 9 Jan 2024
Set the 'ArrayValued' property to 1 for the integral, so that it evaluates the integral of an array/vector valued function/integrand.
Current(1:4)
fplot(@(E) Current(E))
function test_integral = Current(V)
test_integral = integral(@(E) temp(E,V), -inf, inf, 'ArrayValued', 1);
function tempf = temp(E,V)
tempf = V.*exp(-(E.^2));
end
end
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Mobile Fundamentals 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!
