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 =...
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 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...
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...
Given here are the data from a dependent variable and two independent variables. The second independent...
Given here are the data from a dependent variable and two independent variables. The second independent variable is an indicator variable with several categories. Hence, this variable is represented by x2, x3, and x4. How many categories are there for this independent variable? Use a computer to perform a multiple regression analysis on this data to predict y from the x values. Discuss the output and pay particular attention to the dummy variables. y x1 x2 x3 x4 11 1.9...
Input a phrase from the keyboard. For example, input could be: Today is a rainy day,...
Input a phrase from the keyboard. For example, input could be: Today is a rainy day, but the sun is shining. Your program should count (and output) the number of "a"s in the phrase, the number of "e"s, the number of "i"s , the number of "o"s, the number of "u"s, and the total number of vowels. Note: The number of "a"s means the total of uppercase and lowercase "a"s etc. Also: the vowels are a,e,i,o,u. In the above example...
Hello! I'm trying to write a code that will either encrypt/decrypt a message from an inputed...
Hello! I'm trying to write a code that will either encrypt/decrypt a message from an inputed text. I'm having the absolute hardest time getting stared and figuring out how to identify in the code if the input needs to be encrypted/decrypted and identifying the string to encrypt/decrypt with. These are the instructions: Objectives Command line input File input and output Rethrowing exceptions Program Description Gaius Julius Caesar encoded his battle messages so that the opponent could not read them should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT