How can i fix the error "Error using inline Input must be a character vector." and "Error in (line 9) g=inline(f);"

6 visualizaciones (últimos 30 días)
f=exp(2*exp(2)); %I tried this with other functions and it worked
a=0;
b=3;
n=30;
h=(b-a)/n;
g=inline(f);
s=0;
for i=1:n
s=h/2*(g(a+(i-1)*h)+g(a+(i)*h))+s
mensaje=['En la iteracion ',num2str(i),', x es igual a ',num2str(s)];
display(mensaje)
end

Respuestas (1)

Walter Roberson
Walter Roberson el 21 de Oct. de 2019
inline can only be used with character vectors.
Your f is a double precision scalar. If you were to format it into a character vector then would the resulting constant function be something that you would like to apply with an argument Ike you do?

Categorías

Más información sobre Function Creation 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!

Translated by