SAIP
SAIP

Reputation: 99

Find the difference of all the values from the first value with Matlab

This may be very easy question but I am a little bit stuck on that. Is there any easy and fast way to do that?

I will explain with example what I want.

Let us suppose a vector

a= [1,10,20,30,40,50,60,70,80]; 

I want another vector lets say

b= [10-1, 20-1, 30-1, 40-1, 50-1, 60-1,70-1,80-1 ]; 

and then divide all the elements of b by 15 and save in another vector lets say c.

This is just an example in real I have vectors with more than 100 elements so I want to make it automatic.

Thank you in advance.

Upvotes: 1

Views: 48

Answers (1)

Juancheeto
Juancheeto

Reputation: 586

I just tried the following. It works:

b = a(2:end) - a(1);
c = b/15;

Upvotes: 1

Related Questions