MATH 493 MATLAB Materials

Week 1

Simple activities
• Basic plotting
• Try also: On the same set of axes, create a plot of y = x, y = sin(x), and y = x^3. Make one graph blue, one red and one green.
• Create a plot of a bell curve, y = e^(-x^2) for x=-4..4. Hint: you'll need the exp function, and to be careful with the powers again.
• Creating matrices in different ways
• Try also: Create a 5x4 matrix; first 2 columns all ones, second two all zeros
• Create a 4x10 matrix; first row 1,2, ..., 10; second row 2, 4, ..., 20; third row 3, 6, ...30; fourth row 4, 8, ..., 40. Use colon notation, not explicit values.
• Syntax for matrix operations
• Try also: Use a search for 'arithmetic operator' to find the difference between x * x, and x .* x, or x^2 and x.^2.
• Which operations (+, -, *, /, ^) have a 'dot' version as well as the 'regular' version?
• Loop structures
• Try also: Write a loop that displays all even numbers from 2 up to 10
• Write a loop that displays numbers counting by 5 from 0 to 100
• Find the sum of all even numbers between 0 and 40 (inclusive), once using a loop, and a second time using sum
• Heat equation - PDE solving example
• Change the end-point temperatures.
• Change the initial temperature profile in the beam to be a sine wave (which then cools towards a constant temperature).
• Reduce the time interval between steps to speed up the simulation.
• Download the images zip file and unzip it in your MATLAB directory. You should now have a 'rotated' and 'newtest' subdirectories.
• Change the directory where the script finds the images from 'rotated' to 'newtest'.
• Have the process skip over any file with more than 300 columns of pixels.
• Use the 'imresize' command to resize all images to the same size before averaging, rather than finding the average only over the smallest image region.
• Temperature DE - ODE solving example (single variable)
• Look at the code in tempDE.m and relate it to Newton's Law of Heating and Cooling (source DE).
• Run tempScript.m and see the text and graphical output.
• Change the initial temperature -20.
• Change the simulation time interval to t=0..40.
• Increase the cooling coefficient value and see the effect on the model.
• Try to create two plots on the same axes, showing the simulation for two different cooling coefficient values.
• Spring DE - ODE solving example (2-variable system)