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

 채택된 답변

Star Strider
Star Strider 2021년 5월 26일

1 개 추천

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

Szczepan Michura
Szczepan Michura 2021년 5월 26일
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
Szczepan Michura
Szczepan Michura 2021년 5월 26일
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?
.
Szczepan Michura
Szczepan Michura 2021년 5월 26일
yes thank you, that's what I meant
Star Strider
Star Strider 2021년 5월 26일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

질문:

2021년 5월 26일

댓글:

2021년 5월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by