Using diff function with a rate.

2 views (last 30 days)
Abe
Abe on 26 Dec 2014
Commented: Jan on 29 Dec 2014
forceVector = [1:32]';
cellDims = [0 diff([1 4 8 16])];
peakData = mat2cell(forceVector,cellDims);
------------------------------------------------- This is a very nice code, but please I want to work with it by rate for example the percentage going up if the string of numbers become bigger. More precisely, we have string its length is 2^5 so the string will be divided into 5 parts, each part has different rate (1/5, 2/5, 3/5, 4/5 and 5/5). If you have any ideas about this that will be helpful.
  2 Comments
Image Analyst
Image Analyst on 26 Dec 2014
So your string is 2^5 or 32 characters long. How do you divide that into 5 parts? And diff() subtract numbers - the nth element from the (n+1)st element. So why are you doing this on strings instead of numbers? What does subtracting the ASCII values of the characters do for you? And what do you mean by rate? Rate means frequency. I'm getting confused as to the rates , like do you want to subtract the nth element from the (n+5)th element for portions of the array in the 5th chunk?
It's very confusing so please clarify, preferably with an actual string of 32 characters long. Show us what the 5 parts are, and how you would like the diff() command to work (what elements get subtracted), and what the final output should be.
Jan
Jan on 29 Dec 2014
@Image Analyst: I believe that "string" means "vector" actually.

Sign in to comment.

Answers (0)

Categories

Find more on Automotive in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!