unexpected string scalar error?

7 Ansichten (letzte 30 Tage)
Raphael Hatami
Raphael Hatami am 12 Sep. 2019
Bearbeitet: Adam Danz am 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

Antworten (1)

Adam Danz
Adam Danz am 12 Sep. 2019
Bearbeitet: Adam Danz am 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:

Kategorien

Mehr zu MATLAB 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