unexpected string scalar error?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Adam Danz
le 12 Sep 2019
Modifié(e) : Adam Danz
le 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:
0 commentaires
Voir également
Catégories
En savoir plus sur Numbers and Precision dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!