how to define the function y so that when I type (x) I get the value of this function and not its formula, please help :(
syms x
T = taylor (asinh (x), x, 'Order' ,16);
x=input('indicate the value of x = ');
if x>-1 || x<1
y= T ??????????????????????
g=asinh(x);
end
if x<=(-1) || x>=1
y='error!';
g='error'!';
end

 采纳的回答

Define it as a function. (This has been possible since R2012a.)
syms x
T(x) = taylor (asinh (x), x, 'Order' ,16);
figure
fplot(T, [-1 1]*1.35)
hold on
fplot(asinh(x), [-1, 1]*1.35)
hold off
grid
hl = legend('16-Term Taylor Series', 'Analytic Function', 'Location','best');
title(hl, 'sinh(x)^{-1}')
.

5 个评论

thank you for this useful graph, but that's not quite what I had in mind, I wanted a numerical value for the Term Taylor Series variable
so that it can be compared with that calculated by the trigonometric functions of matlab
My pleasure!
Perhaps —
syms x
T(x) = taylor (asinh (x), x, 'Order' ,16);
xv = 0.5
xv = 0.5000
y = T(xv)
y = 
y = vpa(y)
y = 
0.48121175225884076267834812756688
is the desired result?
.
yes thank you, that's what I meant
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by