Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How can I fix my error with the passing a function to another fuction?

1 visualización (últimos 30 días)
Evan Keating
Evan Keating el 26 de Abr. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Im working on a function that that takes 2 points a and b and a function f and out puts a varible and it wont send the value back.
f = @(x) exp^(x);
a = 1;
b = 2;
v = GaussQuadrature(f,a,b)
function value = GaussQuadrature(f,a,b)
ba = (b-a)/2;
ab = (a+b)/2;
value = ab*(f(ba*(-1/(sqrt(3)))+ab)+f(ba*(1/(sqrt(3)))+ab));
end
Then it is return these errors
Error in @(x)exp^(x)
Error in GaussQuadrature (line 4)
value = ab*(f(ba*(-1/(sqrt(3)))+ab)+f(ba*(1/(sqrt(3)))+ab));
Error in Hw10Q3 (line 4)
v = GaussQuadrature(f,a,b)

Respuestas (1)

Andrew Newell
Andrew Newell el 26 de Abr. de 2017
The first line should be
f = @(x) exp(x);

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by