Answered step by step
Verified Expert Solution
Question
1 Approved Answer
An H-bridge is a circuit that can be used to control a motor using simple on/off switches (see figure below) S1 S3 in S2 S4
An H-bridge is a circuit that can be used to control a motor using simple on/off switches (see figure below) S1 S3 in S2 S4 Fig. 1. H-bridge Circuit We can describe the state of the switches in this circuit using an array. Within the array, 0 means the switch is off and 1 means the switch is on. Example: [1,0,1,0] means switches 1 and 3 are on, while 2 and 4 are off The switch state will determine the state of the motor If the switch state is [1,0,0,1] then the motor moves right If the switch state is [0,1,1,0] then the motor moves left If the switch state is [1,0,1,0] or [0,1,0,1] then the motor stalls Otherwise, the motor is off Questions 1. Create a function that checks whether the input vector if in the correct format. If the input array is a 4-element row vector containing only ones and/or zeros, then the function returns 1. Otherwise, the function returns 0. 2. Create a function that returns 1 if the motor moves right, 2 if it moves left, 3 if it stalls, and 4 if the motor is off. You may assume that the input vector is in the correct format. Useful Control Structures and Functions: if, elseif, else, isequal
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started