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

6 views (last 30 days)
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

Answers (1)

Walter Roberson
Walter Roberson on 21 Oct 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?

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!