Using diff function with a rate.

4 次查看(过去 30 天)
Abe
Abe 2014-12-26
评论: Jan 2014-12-29
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 个评论
Image Analyst
Image Analyst 2014-12-26
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 2014-12-29
@Image Analyst: I believe that "string" means "vector" actually.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Automotive 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by