|
Patrice Koehl |
Modeling and Data Analysis in Life Sciences: 2017Lab1: Getting to know MatlabWith this lab, you will start becoming familiar with the Matlab environment and some of its facilities. You will learn:
HandoutsGetting to know Matlab:
Word document (click to download) or PDF document (click to download) Exercise 1: Basic Arithmetic calculations within MatlabEvaluate the following expressions by hand and use Matlab to check the answers:
Exercise 2: assign values to variables; basic operations on arraysTranslate the following math statements into MATLAB commands. For help, the values for the function when x = [1 2 3] are given.
Exercise 3: Control structuresThe Fibonacci sequence
We consider the famous Fibonacci sequence that was originally developed to characterize the population of rabbit. It is define as follows: For example, starting with n = 1, we get: 1,1,2,3,5,8,13,21 ... Write a Matlab script that computes Fn. Check it for n = 5, 10, and 20.
Exercise 4: PlottingWe want to create a graph of over $$[0, \pi]$$. To illustrate what happens when there are too few points in the x domain, let us first try a step size of $$\pi/10$$.
Exercise 5: Errors in programsThe following Matlab programs contain some elementary programming mistakes. Find the mistake and suggest a solution to each or them.
Exercise 6: graphingBiorhythms
Biorhythms were very popular in the 1960s. They are based on the notion that three sinusoidal cycles influence our lives. The physical cycle has a period of 23 days, the emotional cycle has a period of 28 days, and the intellectual cycles has a period of 33 days. For an individual, the cycles are initialized at birth. The figure below shows my biorhythm, which begins on October 26, 1961, plotted for an eight-week period centered around the date this is written, August 28, 2017. The following code segment is part of a program that plots a biorhythm for an eight-week period centered on the date August 28, 2017: t0 = datenum('Oct. 26, 1961'); t1 = datenum('Aug. 28, 2017'); t = (t1-28):1:(t1+28); y1 = 100*sin(2*pi*(t-t0)/23); y2 = 100*sin(2*pi*(t-t0)/28); y3 = 100*sin(2*pi*(t-t0)/33); plot(t,y1,'LineWidth',2); hold on plot(t,y2,'LineWidth',2); plot(t,y3,'LineWidth',2);
|
Page last modified 15 June 2022 | http://www.cs.ucdavis.edu/~koehl/ |