Sep 8, 2015

Lecture 5

Introduction to Plotting
It's great to learn some GUI (sort of?)
Practical exercise for plotting basic graphs, adding titles and labels


























Plotting multiple graphs


 Change line colors and style
Legend
























Clausius-Clapeyron equation and graph































Ballistics context example with kinematics and graph




























Using subplots (code and graphs) to graph multiple graphs in the same window

Polar graphs: plotting fun shapes and experimenting with different thetas and radii
Using plot(x,y), semilogx(x,y), semilogy(x,y), loglog(x,y) functions




HW#3

Question 1:
I verified the answer (distance from London to Mt. SAC using a great-circle distance calculator found at http://www.movable-type.co.uk/scripts/latlong.html).





Question 2:


Question 3:


Question 4:


Question 5:




Sep 3, 2015

Lecture 4

Today is the second day of the second week. I hope to learn how to create functions in MATLAB. I find myself constantly comparing MATLAB to normal C++.

Using trig functions: sin(x), cos(x), tan(x). Inverse trig: asin(x), acos(x), atan(x).
Also tested is the sind(x) function which, calculates sin(x) where x is in degrees. MATLAB calculates trig functions in radians by default. Not pictured, but we were also shown how to search for a function using "help" and "doc".
Practical exercises for trig functions.

Then we did a context example using trig functions to find the net force acting on a hot air balloon. The forces acting on the balloon were the weight, the force of buoyancy, and the force of the wind acting at an angle.








Here are screenshots of the code and results.



Then we went over data analysis functions: mean(x), median(x), and mode(x). MATLAB executes the functions by column. To execute functions by row, use the apostrophe (') after the vector name.
Practical exercises for data analysis functions.
There are some more functions for data analysis: sum(x), prod(x), cumsum(x), cumprod(x). The sum(x) and prod(x) functions are self-explanatory. The cumsum(x) and cumprod(x) functions print each sum as it goes through the vector.
There are also sort functions in MATLAB: sort(x) sorts the elements into ascending order, sort(x, 'descend')  sorts the elements by descending order. Use sortrows(x) and sortrows(x, 'descend') to sort the rows.
We did a context example with calculating precipitation per month and for the entire year.


Then we went over statistics functions: std(x) for standard deviation and var(x) for variance.
Practical exercises for statistics functions.
We went over various functions for complex and imaginary numbers: abs(x) for the magnitude of a complex number, angle(x) for the angle of the complex number represented in polar coordinates, complex(x,y) creates a complex number with x as the real component and y as the imaginary component, real(x) and imag(x) extracts the respective real and imaginary components from a complex number , conj(x) creates a conjugate of a real number.
Practical exercises for complex number functions.

HW#2

As a summary, the homework is done using m-scripts now. Included are screenshots of the code and the results from the command window.

Practical exercises:








Question 1:


Question 2:


Question 3:


Sep 2, 2015

Lecture 3

This is the first day of the second week.

Here, we went over spacing using the fprintf function and fixed point notation (%f) to create neater columns.

In this exercise, we created two vectors, one containing the group members' respective ages and one containing majors. Then we saved the vectors in a .txt file. Below is a screenshot of the actual .txt file. The letters are shown as numbers according to the ASCII codes.
We finally learned to create m-scripts. The above is code for a context example from last week's lecture.


This is a context example on calculating the velocities and accelerations for UDFs using m-script, the fprintf function, and %f.



A context example calculating the acceleration of Voyager 1 and 2.