Train Scholarship MATLAB Personal Research Progress by Genaro Rivera

 

Genaro Rivera

September 14, 2022

Train Scholarship Personal Research MATLAB progress



My first script this week involves the distance formula computing two points’ distance based on user inputs. Firstly, I grasped using comments properly; comments are critical for the programmer. I simultaneously put section headers (two percent symbols), sub-comments (one percent symbol), and worked. Including comments helps with organization and continuation. Secondly, I learned the input function. The input function includes texts the user reads and acts on. The input function must include single quotes to distinguish from variables and text. When running, the script shows the user the text, and the user acts accordingly. For example, here, the text prompts the user to input the coordinates of their desired points. Afterwards, the program computes the distance. Thirdly, I improved my analytic skills. Inability to use sqrt[(x2-x1)^2+(y2-y1)^2] to compute the distance produced analysis. Since I had not defined the four variables (x2, x1, y2, and y1) individually, I resorted to array extraction. I extracted the values for (x2-x1) and (y2-y1), and I stored them under variables xdiff and ydiff. I plugged into the distance formula, and the program ran well. In conclusion, I programmed background actions for a formula computation.

My second script this week involves the input and randi function. Intention being user chosen amount of integers that the program randomizes and extracts the average and largest value. Firstly, I chose the randi function. Since the rand and randn functions involve decimals, I excluded them. Regarding the randi function, 1 is the lower boundary, and the first integer (here, 100) is the upper boundary. The second and third integers (here 1 and c) are the rows and columns of the matrix/ array. Secondly, I typed the input command. Thirdly, since the columns (AKA the number of integers) depends on user inputs, making it a variable, I put the input function (c) for columns. Fourthly, I labeled the randi function as z. Lastly, I used the max and mean function to compute the largest value and average of the randomized integers. In conclusion, I programmed the background of a randomizer that extracts the average and the largest of the randomized integers where the integer amount depends on user.



 

My third script this week involved converting MATLAB to excell. Intention being to convert a MATLAB file to excell. Firstly, I created the MATLAB file. The script involved the length, perimeter, surface area, and volume of a cube as the size increased. I assigned the units along the first row of the cell to the fourth column. The length increased from 1 to 99 in increments of 2 as the Length= [1:2:99]’ command illustrates. Using the length, I computed the perimeter, surface area, and volume using P=12S, SA=6S^2, and W=S^3 respectively. I then put the values in four vector rows with an apostrophe to create a column vector for the table. I put the vector rows from the first column to fourth column. Secondly, I used the xlswrite command (recommended for excell) as xlswrite(‘filename’, variable being transferred). The file saved, so I opened excell and imported the table. In conclusion, I transferred a MATLAB file into excell using the xlswrite function.

My last script this week involved randomizing and averaging four test scores of three students. Intention being to make a program that prompts the user to choose between one of three students to view their average test score. Firstly, I declared the students’ last and first name in the first and second column of the cell respectively creating a 3 (rows) by 2 (column) cell. Secondly, I created a third column with each cell containing four test scores for each student creating a 3 (rows) by 3 (column) cell; randi function randomized the scores on the interval 60-100. Thirdly, I created an input function for the user. Fourthly, I used critical thinking. Since the goal is to display the desired name and score (which is one of the rows), the row the program displays depends on the user thus making the row a variable, so I labeled the input r and placed it where the row is. 











Comments

Popular posts from this blog

Weather Balloon Spring Flight

System Block Diagrams Introduction Week 5

Temperature Sensor week 8