unexpected string scalar error?

13 ビュー (過去 30 日間)
Raphael Hatami
Raphael Hatami 2019 年 9 月 12 日
編集済み: Adam Danz 2019 年 9 月 23 日
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

回答 (1 件)

Adam Danz
Adam Danz 2019 年 9 月 12 日
編集済み: Adam Danz 2019 年 9 月 23 日
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:

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by