How to extract terms from polynomial in syms

2 ビュー (過去 30 日間)
Sohail
Sohail 2014 年 1 月 2 日
編集済み: Azzi Abdelmalek 2014 年 1 月 2 日
Dear all, I want to extract terms from polynomial formed using syms. Here is the code
smys x a
y= x^4 + a*x^3 + 2*a^2*x + 5;
now i need to extract the terms x^4 a*x^3 etc into a new variable that can be used at some other place. like
w=x^4;
r=a*x^3;
d=w+r;
Kindly help on this thanks.
  2 件のコメント
Amit
Amit 2014 年 1 月 2 日
Didn't you answer your own question? Isn't w,r,d are what you want? Am I missing something?
Sohail
Sohail 2014 年 1 月 2 日
Hi amit, I need to extract these terms using y instead. when not using syms we can use y(1) or y(2) and so on to get the required values but here it is symbolic so not sure how to do it. Thanks

サインインしてコメントする。

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 2 日
編集済み: Azzi Abdelmalek 2014 年 1 月 2 日
You can use coeffs function
syms x a
y= x^4 + a*x^3 + 2*a^2*x + 5;
[variable,coefficient]=coeffs(y,x)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by