unexpected string scalar error?

12 visualizaciones (últimos 30 días)
Raphael Hatami
Raphael Hatami el 12 de Sept. de 2019
Editada: Adam Danz el 23 de Sept. de 2019
Hello, I am trying to do taylor series expansion from 0 order to 3 with base point 1 (and estimating f(3)) for the given equation. However, it is giving me an error: 'Expected a string scalar or character vector for the parameter name.' for the line y =...
I believe the problem has something to do with the '1' in the taylor function. But I don't know how else to define the base point.
Can anybody see what I'm doing wrong? Thank you
f = @(x) 25*x.^3-6*x.^2+7*x-88;
sample_at = 3;
trueval = f(sample_at);
syms xx;
fs = f(xx);
for n = 0:4
y = double(subs(taylor(f,xx,n,1), xx, sample_at ));
disp([n, y]);
%now calculate the relative error
end

Respuestas (1)

Adam Danz
Adam Danz el 12 de Sept. de 2019
Editada: Adam Danz el 23 de Sept. de 2019
There are 2 required inputs and 1 optional input to taylor() followed by optional name-value pair arguments. Your call to taylor() contains 4 inputs so matlab is interpreting the extra input(s) as name-value pairs. The name-value pair identifies the parameter with a string scalar or char vector which is why you're getting that error, "Expected a string scalar or character vector for the parameter name.".
Read about this function's inputs and optional name-value pairs here:

Categorías

Más información sobre Numbers and Precision en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by