I'm a noob and the assignment is to create a derivative script without using the polyder function. I have this so far? Does anyone have a more efficient method because I want to learn to code efficiently from the start.

f=[2, -5, -12, 30, 10];
column=size(f);
degree=column(2)-1;
exponents=[degree:-1:0];
deriv1=f.*exponents
deriv2=deriv1.*(exponents-1)

 채택된 답변

Birdman
Birdman 2018년 1월 30일
편집: Birdman 2018년 1월 30일
Using Symbolic Toolbox might be more efficient and easier for you.
syms x
fun=2*x^4-5*x^3-12*x^2+30*x+10
der1=diff(fun,x)
der2=diff(fun,x,2)
and you may get coefficients by coeffs command.
fliplr(coeffs(fun))
fliplr(coeffs(der1))
fliplr(coeffs(der2))

댓글 수: 1

Thanks I didn't know about syms, or the functions diff and coeffs. I'll look more into them.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

+ +
2018년 1월 30일

댓글:

+ +
2018년 1월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by