How do I create a matlab function using polyder that not only gives the coefficients but also gives the equation

4 ビュー (過去 30 日間)
My code so far (doesnt work):
function derivativecoefficient = derivpolycalc()
a = input('Enter the coefficent of the polynomial')
x == x
n = input('Enter the power of each x')
derivativecoefficient = polyder(a)
derivative = derivativecoefficient*x^(n - 1)
end
If i just do it where it shows the coeeficents, I could simply do:
function derivativecoefficient = derivpolycalc()
a = input('Enter the coefficent of the polynomial')
derivativecoefficient = polyder(a)
>> derivpolycalc
Enter the coefficent of the polynomial[3,2,5]
a =
3 2 5
derivativecoefficient =
6 2
ans =
6 2
BUT I want a code that will display
6x^2+2x+0..
or maybe it could display
6x^5+2x^3+0
depending on what the original function was.

採用された回答

gonzalo Mier
gonzalo Mier 2019 年 4 月 29 日
編集済み: madhan ravi 2019 年 5 月 12 日
I think you need here the function poly2sym:
  4 件のコメント
gonzalo Mier
gonzalo Mier 2019 年 5 月 12 日
編集済み: gonzalo Mier 2019 年 5 月 12 日
Accept the answer if it worked for you! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by