how can i calculate the derivative of an x vector?
1 回表示 (過去 30 日間)
古いコメントを表示
Starts with an x vector created using linspace with a starting point of -5 and ends at +4 and at least 50 data points.
Evaluate the function f = 2x4 – 5x3 -12x2 + 30x +10 as a function of the MATLAB vector By hand, calculate the first derivative and then evaluate using the same x-vector. By hand, calculate the second derivative and then evaluate using the same x-vector.
Plot the three equations using different line color and different markers. You may use the extended plot command or roots.
Add a graph title, axes titles, and a legend.
2 件のコメント
James Tursa
2018 年 9 月 5 日
What have you done so far? What specific problems are you having with your code? Do you know how to take the derivative of a polynomial by hand? Do you know how to evaluate polynomials in MATLAB?
採用された回答
madhan ravi
2018 年 9 月 5 日
編集済み: madhan ravi
2018 年 9 月 5 日
Try the below:
syms f(x)
f = 2*x.^4 - 5*x.^3 -12*x.^2 + 30*x +10
first_derivative = diff(f)
second_derivative = diff(f,2)
%solved symbolically till here
%using numerical method from the above
x=linspace(-5,4,50)
subplot(3,1,1)
plot(subs(x),subs(first_derivative),'*r-')
xlabel('x')
ylabel('first derivative')
title('1ST DERIVATIVE')
legend('FIRST DERIVATIVE')
subplot(3,1,2)
plot(subs(x),subs(second_derivative),'og-')
xlabel('x')
ylabel('second derivative')
title('2ND DERIVATIVE')
legend('SECOND DERIVATIVE')
subplot(3,1,3)
plot(subs(x),subs(f),'sqb-')
xlabel('x')
ylabel('equation')
title('FUNCTION')
legend('FUNCTION')
Start getting familiar with the Matlab functions soon , the sooner the better.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!