Oct 20, 2015

HW#13

All questions use a message box to output results.

Question 1: Solving symbolically.
Solving for distance from a pivot point to the center of gravity of a pendulum using a formula for frequency. I just used solve() to find L.

Question 2: Projectile
Solve for horizontal and vertical distances. Using subs() to substitute real values for symbolic data.
Question 3: Weather balloon
Question 4: Spring


Question 5: Trigonometric Function

Oct 15, 2015

Lecture 14

Today we're continuing symbolic functions.
Plotting some functions with set intervals.

Plotting trig graphs, multiple graphs in one, and parametric graphs.

Some symbolic functions: 

This is some screenshots of a few of the different three-dimensional plots using symbolic equations.

Practice problems using three-dimensional plotting functions to plot a symbolic equation.














































Ballistics context example. Using ezplot() to plot projectile motion and range.











































Next is calculus in MATLAB. There are functions that differentiate equations.

We modified the ballistics program to use calculus to find the optimum angle for the maximum range and the maximum range.
























Next is integration. This table shows some integration functions.

HW#12

Question 1: Some practice exercises dealing with symbolic equations and subs()

Question  2: Pendulum
I didn't do anything special for this question. The solution is a very simple 3 line program.
I just created a symbolic equation and then solved for 'L' in the equation.


Question 3: Chemical processes
We had done this question before using matrices and linear algebra. This method is much faster, but the answers are not as accurate as using linear algebra. There is nothing special with this program either.

Oct 13, 2015

Lecture 13

Modified the planetary data program to extract different data.


Today we are focusing on symbolic algebra. This screenshot shows the practice exercises we did in the beginning. The symbols and expressions are going to be used throughout the class.


Using numden() to extract the numerator and denominator of a symbolic expression.

Typing mupad opens a MuPad window.
Practice exercise
An example using solve() to symbolically solve for Q.














Solving a system of equation: originally with linear algebra, and then with solve().
This example containing free-fall and kinematics. Solve for the range.




HW#11

Most of the problems were fairly easy to do, almost on-par with the practice exercises from in class.

Questions 1 and 2: practice exercises (pretty much)


Question 3: Simple encoding
I used if statements inside of a while loop to change the odd and even elements into different characters. The odd elements had a different type of encoding than the even elements. Also used was a menu() function to ask the user if they want to decode the text.








Question 4: Planetary data
Practicing struct arrays
Question 5: Cell arrays and extracting data

Oct 8, 2015

Lecture 12

This is an engineering class and not a programming class, so we are now going over data types 6 weeks in. The picture below is from the lecture notes. It shows the various data types MATLAB matrices can store.

realmax() and real(min) gives the maximum and minimum value a double precision floating point, which is the default number data type in MATLAB, can hold. 
Using single() and double() to convert numbers to single and double data types respectively. 
Practice exercises:
Not shown in screenshots, but we went over sparse arrays, cell arrays, and structure arrays. Very cool. I had previously used cell arrays when I used dialog boxes to ask for user input. I have only used structs one time to implement doubly linked lists in C++. 

HW#10

Question 1: Solve a system of 7 equations. Use tic() and toc() functions to test whether matrix left division is faster or matrix inverse is faster. The notes said that left division was generally more accurate and faster, but in this case the inverse was faster and both gave the same results.















Question 2: This question was similar to the desalination question from the example in class. The most difficult part was figuring out how to solve for the third unknown. It took a few minutes, but I finally realized that the third variable x could be moved to the right-side of the equations. The first equation would have a 0 in place of the coefficient for x.
Question 3: Similar to the truss example from class, but with a force applied at an angle. I just modified the program from class to allow the user to enter the force applied and the angle at which it was applied.
All of the problems could be solved using a generic function ask_matrix(). It asks for the amount of unknowns needed, then uses two while loops to allow the user to enter in the appropriate amount of coefficients. The, the user is prompted to enter the answers to the equations. It will return two matrices, one containing the coefficients, and one containing the answers (which is transposed). I could also have it calculate the unknowns with 1 extra line of code.

Oct 6, 2015

Lecture 11

Mahmoud's Matrices continued...

Context example: calculating the electrical current. Ask for user input for values of resistance and voltage



This first program uses inverse and matrix multiplication.



Changing line 16 from the first program to use left division instead of inv(). It shows the same results.

Context example: desalination



















More or less the same as the electric_current.m program.

Context Example: A force on a statically determinate truss.
































The same concept as the other problems, except with 6 equations and 6 unknowns. The process is more or less the same.

Using eye() to create identity functions.
pascal() and rosser