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

6 次查看(过去 30 天)
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

回答(1 个)

Walter Roberson
Walter Roberson 2019-10-21
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?

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by