Answers

Question and Answer:

  Home  MATLAB

⟩ A question about matlab functioni have used diff(y,x) for a function in matlab and it has give me a answer that has abs(a,b) in it.wht is this function according to its two arguments?ali 08-1-2016?

diff(y) means calculates differences between adjacent elements of y along the first array dimension

y= [1 1 2 3 5 8 13 21];

z=diff(y)

z =

0 1 1 2 3 5 8

this is the difference between the adjacent columns (second column-first column) and the result of diff function that is number of column of z is one less than the number of column of y

diff(y,x) where x=2

diff function will call two times (x times)

y= [1 1 2 3 5 8 13 21];

x=2;

z=diff(y,x)

z= 1 0 1 1 2 3

number of column of z is two less than y

 238 views

More Questions for you: