error using integral function
26 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Raul Rodriguez
el 5 de Mayo de 2020
Comentada: Raul Rodriguez
el 5 de Mayo de 2020
hi everybody,i`m trying to execute this code...
syms x f(x)
f(x)=exp((-x.^2)/2)
f_matlab = matlabFunction(f(x))
v1 = integral(f_matlab,1,2)
but when i do it, i get this problem
Unable to use a value of type function_handle as an index.
Error in (name of script) (line 55)
v1 = integral(f_matlab,1,2)
Does anyone know how to solve it?
0 comentarios
Respuesta aceptada
Steven Lord
el 5 de Mayo de 2020
Rename the variable you've defined named integral so that it doesn't shadow the integral function included in MATLAB.
Más respuestas (1)
David Hill
el 5 de Mayo de 2020
Looks like you are trying to do numerical integration, then no need for symbolic variables.
f=@(x)exp(-x.^2/2);
v=integral(f,1,2);
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!