Posts

Showing posts from October, 2022

MATLAB While Loop (Week 7)

Image
  Genaro Rivera October 25, 2022 MATLAB While Loop (Week 7) While Loop This week, I focused on the while loop. A while loop repeats until a condition is met. The best way to think about coding is by visualizing yourself talking to someone. For example, above, you are saying “X is one. While X is less than 5, add 1 to it. If x is below 5, keep adding 1 to it.” Eventually, x becomes 5 which is where the loop ends. However, infinite loops exist as seen below. Here, x will always be less than 5; if you keep subtracting 1 from 1, it will never be greater than or equal to 5. The picture on the left displays the output (AKA the command window). The command window rapidly subtracts 1 for ever until you stop it by pressing control c; I stopped it at -214106. In conclusion, while loops repeat until a condition is met. However, if the condition is never met, the loop repeats forever. While Loop and For Loops Differences Here, both functions do the same thing, but the for loop is better....

MATLAB Week 6

Image
  Genaro Rivera October 21, 2022 MATLAB For Loop (Week 6) For Loop This week, I decided to focus on the for loop. The for loop has special features. The for loop repeats a specified number of times. For example, above the ee = 3:6 states to go from 3 through 6 in increments of one. X(ee) extracts the term corresponding to the ee value from the row vector (if ee was 3 it extracts the 3 rd term from the row vector, if ee was 4 it extracts the fourth term from the row vector, etc…). The for loop repeats this process until ee runs out of values (in this case after ee = 6). Regarding the English counterparts, this makes sense; read it as the English language. For ee = 3 will equal 3*2 and so on. Below is a table that goes over each induvial step. Step Number ee X(ee) 1 3 [0 0 6] 2 4 [0 0 6 8] 3 5 [0 0 6 8 10] 4 6 [0 0 6 8 10 12] N...

System Block Diagrams Introduction Week 5

Image
  Open Loop vs Closed Loop Systems For this week I chose system block diagrams because my ECE 103 class and, moreover, my ECE 294 class use system block diagrams, and people, including me, are unfamiliar with them, so I chose to research system block diagrams. Differing block diagrams are open loop and closed loop systems. Both, open loop and closed loop systems, have similarities. Any control system will take and process an input and generate an output. Internally, control systems are divided into two sections: the controller section and process section. The controller section controls the amount of input required to process an input. The process section processes the input to generate the output. Despite similarities, open loop systems have unique characteristics. Regarding open loop systems, the reference point is independent to the output. No feedback signal that indicates how to vary the input to get the desired output exists. For example, a toaster does not know when the brea...

MATLAB week 4

Image
  Genaro Rivera 10/04/2022 TRAIN scholarship week 4 MATLAB If/else statements This week, I learned to use if/else statements. If/else statements are integral for coding, so I enjoyed learning to use if/else statements. Here, I created a script that displays what grade average a student got. Firstly, I used the randi function to generate a random number from 1-100. Secondly, I created an if statement with different branches. MATLAB reads the elseif statements from top to bottom until it runs into a true statement. For example, if the grade average is an 85, it detects AVG<60, AVG<70, and AVG>=70 && AVG<80 as false. It moves on and computes AVG>=80 && AVG<90 as true, so it stops there and displays it. Like I said, MATLAB reads top to bottom until it finds a true statement and reacts to the command. If it finds a true statement and the statement right after is also true, MATLAB will only compute the first one it saw (first come first serve)....