Algorithm:
1.
CheckValid(vector)
{
int size = vector.size();
if not(size isequal 4)
return 0;
else
for i from 0 to 3:
{
if not(vector[i]
isequal 0) and not(vector[i] isequal 1):
return 0;
}
return 1;
}
2.
MotorDirection(vector)
{
if (vector[0] isequal 1) and (vector[1] isequal 0) and
(vector[2] isequal 0) and (vector[3] isequal 1)
return 1;
elseif (vector[0] isequal 0) and (vector[1] isequal 1)
and (vector[2] isequal 1) and (vector[3] isequal 0)
return 2;
elseif ((vector[0] isequal 1) and (vector[1] isequal
0) and (vector[2] isequal 1) and (vector[3] isequal 0)) or
((vector[0] isequal 0) and (vector[1] isequal 1) and (vector[2]
isequal 0) and (vector[3] isequal 1))
return 3;
else
return 4;
}
C code:
1.
int CheckValid(int *vector)
{
int size = vector.size();
if(size != 4)
return 0;
else
for i from 0 to 3:
{
if ((vector[i]
!= 0) && (vector[i] != 1)):
return 0;
}
return 1;
}
2.
int MotorDirection(int *vector)
{
if ((vector[0] == 1) && (vector[1] == 0)
&& (vector[2] == 0) && (vector[3] == 1))
return 1;
elseif ((vector[0] == 0) && (vector[1] == 1)
&& (vector[2] == 1) && (vector[3] == 0))
return 2;
elseif (((vector[0] == 1) && (vector[1] == 0)
&& (vector[2] == 1) && (vector[3] == 0)) ||
((vector[0] == 0) && (vector[1] == 1) && (vector[2]
== 0) && (vector[3] == 1)))
return 3;
else
return 4;
}
Thank you.
art A Based off Week 2 Content ее An H-bridge is a circuit that can be...
You are to create a new application that will execute on your Arduino platform based upon the Blink example that is available in the Arduino Examples folder that you downloaded as part of the IDE. Your application will use a toggle switch to interface with the user. The application will operate by controlling the LEDs based upon the position of the toggle switch. If the user moves the LEDs until new user input is provided. When the user moves the...
must be done in matlab
Part B (Based off Week 3 Content) Newtons Method approximates a root of a function by iterating through the equation where n is the nth estimate for the root of the function f(z). In order to it- erate through this method, we need to provide an initial guess for the root, For example, if we apply this method to f(z) = sin(z) using note that f(cos(r) = 1, we sin(1) =-0.5574 cos(1) sin(-0.5574 ) cos(-0.5574)...
Hi, I need some help with the a
Mealy and Moore Logisim circuit drawings for part of a project, the
details are below. Also here is an example of the mealy (I think)
circuit that should work if the gates are changed to two inputs. If
that is the case please confirme, then I really only need the
Moore...
The Clean Laundry Company (CLC) is interested in reducing the
risk of personal injury to their customers while operating their
washing...
The elevation profile for the above plot of land is [1, 2, 3, 1, 2,1,4, 8, 2, 2, 2, 0]. One can form the largest cross sectional area by excavating soil at array index 1 and extend that area all the way to array index 10 forming a rectangle of area 2x9 = 18 square units. Thus this is the largest retention pond cross sectional one can create from this terrain. Remember the proposal calls for digging into the ground,...
ONLY NEED SOLUTION TO QUESTION 4 PLEASE, THANK
YOU
(PLEASE MAKE SURE TO PLOT THE SOLUTION IN
MATLAB)
Part A (Based off week 7 Workshop content) Consider the RLC circuit where R = 5, C = 1, L = 4 and Vs = 8. 1. Use circuit analysis laws to show that the resistor's voltage and induc tor's voltage can be modelled as the system of ODEs: L RC i the system of ODEs 3. Verify your answer for question...
K-means clustering K-means clustering is a very well-known method of clustering unlabeled data. The simplicity of the process made it popular to data analysts. The task is to form clusters of similar data objects (points, properties etc.). When the dataset given is unlabeled, we try to make some conclusion about the data by forming clusters. Now, the number of clusters can be pre-determined and number of points can have any range. The main idea behind the process is finding nearest...
IN C++ Please!! Declare a global integer constant called SIZE and initialize it to 10. • Declare a global enum variable that will support 10 values – each representing an ant colony {A, B, C, D, E, F, G, H, I, J}. • In the main function, o Declare a 2-dimensional array of size the global integer constant, SIZE. The number of rows and columns should be equal to SIZE, which would make this a square matrix. This array will...
Assignment You will be developing a speeding ticket fee calculator. This program will ask for a ticket file, which is produced by a central police database, and your program will output to a file or to the console depending on the command line arguments. Furthermore, your program will restrict the output to the starting and ending dates given by the user. The ticket fee is calculated using four multipliers, depending on the type of road the ticket was issued: Interstate...
This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens.You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a...
In a game of Tic Tac Toe, two players take turns making an available cell in a 3 x 3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A stalemate occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win. Write a program...