如何在Matlab脚本中将泰勒级数系数存储到数组中 [英] How to store Taylor series coefficients into an array in Matlab script

查看:137
本文介绍了如何在Matlab脚本中将泰勒级数系数存储到数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是在.m脚本的上下文中进行的.

This question is in the context of a .m script.

我知道如何获得一个函数的泰勒级数,但是我看不到任何命令可以使该系列的系数存储到数组中-sym2poly似乎不起作用.

I know how to get the Taylor series of a function, but I do not see any command that allows one to store the series' coefficients into an array – sym2poly does not seem to work.

如何将系数存储到数组中?例如,此功能:

How does one store coefficients into an array? For example, this function:

syms x
f = 1/(x^2+4*x+9)

我们将如何获得泰勒系数? fntlr无效.

How would we be able to get the Taylor coefficients? fntlr did not work.

推荐答案

使用您的示例,符号 coeffs 函数获得系数向量:

Using your example, the symbolic taylor and coeffs functions can be used to obtain a vector of coefficients:

syms x
f = 1/(x^2 + 4*x + 9);
ts = taylor(f,x,0,'Order',4) % 4-th order Taylor series of f about 0
c = coeffs(ts)

返回

ts =

(8*x^3)/6561 + (7*x^2)/729 - (4*x)/81 + 1/9


c =

[ 1/9, -4/81, 7/729, 8/6561]

使用 vpa

Use vpa or double to convert c to decimal or floating point.

这篇关于如何在Matlab脚本中将泰勒级数系数存储到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆