unexpected string scalar error?

7 views (last 30 days)
Raphael Hatami
Raphael Hatami on 12 Sep 2019
Edited: Adam Danz on 23 Sep 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

Answers (1)

Adam Danz
Adam Danz on 12 Sep 2019
Edited: Adam Danz on 23 Sep 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:

Categories

Find more on MATLAB 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!