f = [2, -4, 7, 5] the distance between 1 and its right neighbour (ε1 ) is in matlab

You can simply subtract the first element of the array from the second element to compute the distance between them in MATLAB.

Here's an example:

main.m
f = [2, -4, 7, 5];
epsilon1 = f(2) - f(1); % distance between 1 and its right neighbour
88 chars
3 lines

In the example above, f(2) gives the value at index 2 of the array, which is -4. Similarly, f(1) gives the value at index 1 of the array, which is 2. Finally, subtracting the two gives the distance between them, which is epsilon1 = -4 - 2 = -6.

related categories

gistlibby LogSnag