Matlab derivative code
Favorites|Homepage
Subscriptions | sitemap
HOME > Mathematics > Matlab derivative code

Matlab derivative code

[From: ] [author: ] [Date: 11-11-11] [Hit: ]
a. Enter a vector x and assign size (x) to the variable n.b. Extract the second component of n and assign it to a variable s.c. Find out what [ 5:-1: 1] does.......
Develop a Matlab strategy whereby you can start with polynomial p represented by a vector x, and produce the vector y that represents its derivative. You won’t know the degree of p beforehand. Finding the degree is part of the strategy.

There are some hints:
a. Enter a vector x and assign size (x) to the variable n.
b. Extract the second component of n and assign it to a variable s.
c. Find out what [ 5:-1: 1] does.
d. What do the following commands do? diag([a b c d]) , zeros( 1, n)
e. Start with a any matrix M. Add a row of zeros to the bottom to obtain M1.
f. Then add a column of zeros to M1.
Note: (To t add a row vector z to the bottom of a matrix M, the command it
[M;z]. To augment a matrix, with a column y, write [M,y]. The transpose x’ is
very useful. )

-
Whenever you differentiate a polynomial, you reduce its degree by 1.

If you have a vector representing the polynomial (which I assume is a row vector containing the coefficients of the polynomial in question), you want the first element to become zero, and you need to multiply all elements by its position relative to the end (multiply the last element by 1, the second last be 2, the third last by 3, the fourth last by 4, etc.

Think about what happens when you differentiate
x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x^1 + 1.

You get
0x^10 + 10x^9 + 9x^8 + 8x^7 + 7x^6 + 6x^5 + 5x^4 + 4x^3 + 3x^2 + 2x + 1

So you want your code to, for example, set

P = [1 1 1 1 1 1 1 1 1 1 1] to
y = [0 10 9 8 7 6 5 4 3 2 1]

Try the following:

y = zeros(length(P));
for i = 2: length(y)
y(i) = P(i)*(length(P) + 1 - i);
1
keywords: derivative,Matlab,code,Matlab derivative code
New
Hot
© 2008-2010 http://www.science-mathematics.com . Program by zplan cms. Theme by wukong .