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

6 Ansichten (letzte 30 Tage)
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

Antworten (1)

Walter Roberson
Walter Roberson am 21 Okt. 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?

Kategorien

Mehr zu Function Creation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by