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

5 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Walter Roberson
Walter Roberson il 21 Ott 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?

Categorie

Scopri di più su Function Creation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by