Course Outline

List the topics covered within each week.

Week

Topic(s)

1

Introduction to MATLAB Programming

 

LECTURE WORK :

Opening MATLAB and introducing the editor, command prompt, workspace, variables, arrays, operations on arrrays and plotting)

 

HOMEWORK :

      a) Evaluate and store the sine and cosine values of the values from 0 to 360 10 by 10 and store them to the separated arrays called sines and cosines before plotting the sinusoidal graphs of these arrays, 

      b) Evaluate the Tangent of these values by simply using these arrays

2

Variables and Control Structures (if, else-if, while, for…) with examples  Part 1

 

LECTURE WORK :

Defining Variables, storing values to the variables, operations on the variables,

Write a small program that simulates 1000000 throws of a dice and show that each face comes up at approximately same rate

 

HOMEWORK :

Solution of Grade book example using if, else-if structures (retrieve a number from the user  while he doesn’t enter (-1) and display the corresponding letter grade on the screen

 

3

Variables and Control Structures (if, else-if, while, for…) with examples  Part 2

 

Writing a program that continuously takes values from the user and converts them to 0 if the entered number is even and converts them to 1 if the entered number is odd. The program will also display whether the sum of all entered numbers are odd or even

 

HOMEWORK :

Writing a MATLAB program that determines the solution of 5.th degree mathematical expression for any given a,b,c d,e of;

ax^4+bx^3+cx^2+dx+e

 

4

Functions  and Arrays

 

LECTURE WORK :

Define 3 arrays called a,b and c, then write the functions topla, cikart carp, bol and us. Using these functions calculate ((3x4)^5-2)/5. Finally plot the results

 

HOMEWORK :

a)Study recursive functions and write the function “faktoriyel” recursively without using the built in factorial function

b) write a program that calculates the transpose of an array

 

5

2 dimensional arrays in MATLAB

Usage of 2 dimensional arrays and ploting them in 3D in MATLAB

 

LECTURE WORK :

Again define 3 arrays called a,b and c (each 2D this time) , then write the functions topla, cikart carp, bol and us. Using these functions calculate ((3x4)^5-2)/5. Finally plot the results

 

HOMEWORK :

Plot the 3d graph of randomly filles 10 by 10 2 dimensional array after storing them in a 2D array

6

Accessing to array indexes, sorting and swapping

 

LECTURE WORK

1) Assume you have a class of 40 students, assign them random grades between 0 and 100

Then plot the curve of the class

2) Writing the complete program of TOMBALA game. 

HOMEWORK :

Create a an M x N array, fill it with random numbrs between a and b (taken from the user) Sort both rows and arrays

7

Usage of functions calling other functions and passing arrays between functions. Debugging and troubleshooting in Matlab Programs

 

LECTURE WORK :

1) A cont. time x(t) signal is given. Plot x(t) versus t = 0 : 0.01 : 5, x(t) = 10e −t − 5e −0.5t 

2) Repeat part (1) for x(t) = 10e −t + 5e −0.5t 

3) Finding the perfect numbers up to the given numbers. (Perfect number is a positive integer that is equal to the sum of its propoer positive divisors, that is, the sum of its positive divisors excluding the number itself.)

4) Finding the subtraction of the sum of the odd numbers in an array from the numbers at the even indexes in the same array.

HOMEWORK :

An exponentially damped sinusoidal signal is defined by x(t) = 20sin(2π × 1000t − π/3)(e −at) where the exponential parameter a is variable, taking on the set of values a=250, 500, 750, 1000. For each a value draw x(t) signal for −2 ≤ t ≤ 2 miliseconds. Observe the effects of a on the signal. Using subplot command plot x(t) signals for all a values on the same graph. 

 

8

HOMEWORK : Create a vector which is composed of 100 random integers from 1 to 99. By creating a matrix, place each element to different rows one by one according to the ranges. There will be 10 different ranges (1-9, 9-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-89, 90-99). Finally, count the number of values belonging to each range by using another vector that has all ones initially.

9

Plotting, and some plotting properties of Matlab (Plot, subplot, stem, title, axis, legend, set, fill, grid, hold,…)

 

LECTURE WORK :

Midterm Solution (see in Lecture Notes link) 

HOMEWORK :

Take a value called "n" from the user, then Create two arrays with size floor(n/2) called arrayodd and arrayeven and fill them with random odd / even  numbers between 1-100. Then store them into another array called arrayone such that;

1.st element of arrayone  will be the first of arrayodd,

2.nd element of arrayone  will be the first of arrayeven + first of arrayone,

3.rd element will be the second of arrayodd + first 2 elemets of arrayone

and goes like this

10

Some built in functions, (int, trapz, diff, rand, mod, zeros, find, exp …),  their usage methods and examples

LECTURE WORK :

Write a program in which there will be n elements (the n value will be taken from the user) which will be shown by red diomonds and they will move in an area of 100x100 with random speeds and to random directions. they will also reflect when they hit to the borders or to eachother

HOMEWORK :

Write a program to find the number of days between 2 dates. User will enter 2 different dates where the first one should be older than the second one. This program should take into account the leap year (366 days in a year, occurs every 4 years period) as well as the number of days between months. There will be two different scenarios depending on whether or not the first month is smaller or larger than the second month.

11

Developing Matlab programs including “Mobile objects” for simulation purpose

 

LECTURE WORK :

Write a program in which there will be n elements (the n value will be taken from the user) which will be shown by red diomonds and they will move in an area of 100x100 with random speeds and to random directions. they will also reflect when they hit to the borders or to eachother

HOMEWORK :

Each new term in the Fibonacci sequence is the summation of the previous two terms. The first 10 Fibonacci sequence terms are as follows:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Write a Matlab code;

1) that finds the summation of both the even-valued terms and the odd-valued terms separately for the first 200 terms. This program should also count the total number of even-valued terms and the total number of odd-valued terms.

2) that finds the summation of both the even-valued terms and the odd-valued terms separately, where the term values do not exceed 2000. This program should also count the total number of even-valued terms and the total number of odd-valued terms.

12

Managing the distributed data by centralized way using multidimensional arrays in the simulations Part 1

 

LECTURE WORK :

Learning how to manage centralised data by differend nodes runing in the same area (a simulation perspective)

HOMEWORK :

Write a Matlab program for the following dice game:

A player rolls two dice. Each die has six faces. These faces contain 1, 2, 3, 4, 5 and 6. For each roll, the sum of the two upward faces is calculated.

Case1) If the sum is 7 or 11 on the first throw, the player wins.

Case2) If the sum is 2, 3 or 12 on the first throw, the player loses.

Case3) If the sum is 4, 5, 6, 8, 9 or 10 on the first throw, the sum becomes the player's point. In order to win, player must continue rolling two dice until the new sum will equal to the player's point. In that case, you should count how many times the roll has thrown to reach the point.

13

Managing the distributed data by centralized way using multidimensional arrays in the simulations Part 2

 

LECTURE WORK :

Tombala example as Recitation