Question

In: Computer Science

So, I'm trying to get revolutions/second from a given binary data. for example, the input binary...

So, I'm trying to get revolutions/second from a given binary data.

for example, the input binary data is:

V=[0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 ]

let's say the distance between each value is arbitrary (for this example, you can use 0.1). Each 1 represents a full rotation of a bike pedal, and I'm trying to calculate the pedal rate from a given binary dataset in Matlab. How would I do so?

EDIT for clarification:

So, I'll be receiving data from a bike as a binary vector (0s and 1s). Each 0 or 1 represent a measurement. I think each number represents like a certain time. So the vector [0 1 0 0 1 ] would mean two rotations and just a guess at the time between each value is .1 seconds. So the cadence would be 1 rev/.3s.

I'm trying to figure out how to write a program to read the given vector and output a cadence.

Solutions

Expert Solution

I'm assuming that at every occurrence of 1 in the data set, the bike pedal completes its one rev.

so to calculate rev/s we need total revolutions completed in 'T' time::

so for revolutions we we will calculate number of 1's in data set and subtract 1 from it(since we dont know exactly how much time it took for the first revolution).

To calculate time: we will take difference of indices of first and last occurrence of 1 in given vector, this will give us our time period

eg. in our dataset [0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 ] -> we have 5 rev and

index of first 1 is 2;  index of last 1 is18 T=16

rev/s= 5/16

V=[0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 ]
arb=0.1;
rev=sum(V)           %will give total number of ones in our vector
ind=find(V)          %it will return vector with indices of non-zero elements of in a matrix,
                     %in our case vector with indices of 1's
T=ind(end)-ind(1)    %last occurence of 1 - first occurence of 1
frequency=(rev-1)/(T*arb)          %calculating frequency(revolution per second)

(for any doubt in solution just leave a comment else please press the like button)


Related Solutions

So, I'm trying to get an average revolutions/minute from an input vector. Here's a sample vector:...
So, I'm trying to get an average revolutions/minute from an input vector. Here's a sample vector: V=[10200 11000 11800 12300 13100 13900 14400 15020 15850 16250] The units are in ms so 10200 is 10.2 seconds. The revolutions is between every successive value. So 11000 - 10200 is 1 revolutions per 800 ms and et cetera. I need help figuring out a code that will allow me find the average cadence from the whole dataset. Thank you in advance
Javascript array of objects: I'm trying to get the input into an array of objects, and...
Javascript array of objects: I'm trying to get the input into an array of objects, and then display the information in a table using a for loop, but I don't think my path is right <!DOCTYPE html> <head> <title>Form</title> <meta charset="utf-8" /> <style media="screen"> h1 { text-align: center; } div { background-color: #pink; border: 2px solid green; padding: 15px; margin: 65px; } </style> <script> var list = []; total = 0; text = ""; function Product(item, quantity, costs){ this.item =...
(C++) Hey, so I'm trying to make a Remove() and Add() function for a Binary Search...
(C++) Hey, so I'm trying to make a Remove() and Add() function for a Binary Search Tree (NOT USING RECURSION), can you help? For 3 cases: no child, 1 child and 2 children also for Remove(). This is the function to find the node to be deleted/added TreeNode* PrivateFind(const T& tWhat)    {        //Start from head        TreeNode* tWalk = mHead;        while (tWalk != nullptr)        {            //If found then return...
I'm working on python code which is substring matching. For example, the given string is input...
I'm working on python code which is substring matching. For example, the given string is input "CTTGTGATCTCGTGTCGTGGGTAG", and a substring we want to find in the main one is "GTGG". So the code will print out the position and the substrings in the main which has exactly one different position. For example, start at position 4 the substring is GTGA since there is only one letter different, and so on. Even though we know that string index starts at 0,...
I'm having trouble with my do while loop. I'm trying to get it where if the...
I'm having trouble with my do while loop. I'm trying to get it where if the user enter's 3 after whatever amount of caffeinated beverages they've entered before then the loop will close and the rest of my code would proceed to execute and calculate the average price of all the caffeinated beverages entered. Can someone please help me with this? Here's my Code: import java.util.Scanner; public class Main { public static void main(String[] args) { CaffeinatedBeverage[] inventory = new...
I'm trying to get the union of two arrays and I tried making a loop that...
I'm trying to get the union of two arrays and I tried making a loop that does so. I tried also making the loop give me the size of the array as well from the union of the two arrays. Please check my loop to see what is wrong with it because it is not doing what I want it to do. I'm also not sure how to get the correct size of the array after the two arrays have...
I'm trying to make this C++ loan calculator but I can't get the program to output...
I'm trying to make this C++ loan calculator but I can't get the program to output what I need. For instance I know the formula is right and when I enter 100000 1.5 20 as my cin variables I should get 482.55 but I get 1543.31. What am I not seeing as the issue? Also this should cout only 2 decimal places right? I'm not allowed to alter the #include and add any fixed setprecision. This is what I have....
Trying to discover a solution for sending data from the underwater facility to the surface so...
Trying to discover a solution for sending data from the underwater facility to the surface so that it can be uploaded to the internet from a research facility on the edge of Mariana Trench, roughly 1 mile below the surface of the ocean. All data will be stored in Amazon cloud database for instant access by scientists from around the World. This needs to be uploaded to (AWS) amazon web services. WHAT CATEGORIES WILL I NEED TO CONSIDER for this...
Write a driver to get a String input from keyboard and if the input string has...
Write a driver to get a String input from keyboard and if the input string has less than 10 characters, throw a StringTooShortException. public class StringTooShortException extends Exception {     //-----------------------------------------------------------------     // Sets up the exception object with a particular message.     //-----------------------------------------------------------------     public StringTooShortException()     {         super("String does not have enough characters");     } }
I was trying to implement a simple binary search tree using this given class of bst...
I was trying to implement a simple binary search tree using this given class of bst in c++ public: BST(); ~BST(); void insertKey(int newKey); bool hasKey(int searchKey); std::vector<int> inOrder(); int getHeight(); however; i am still required to use another class for the nodes as a pointer and i need to manage memory leak. in main we should ask for the numbers we need to insert in the binary search tree and also let the user end it with a letter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT