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 5 to 360 15 by 15 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,

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

b) Writing a function that swaps the indexes of two elements in an array and using this function to sort the elements in the array from the small to large

c) Generate N random numbers from 34 to 88 and store the odd numbers into array1, even numbers into array2

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

 

LECTURE WORK :

a) Writing a program that continuously takes 10 numbers from the user and displays whether the entered number is odd or even. Finally the program will also display whether the sum of all entered numbers are odd or even

b) Writing two functions that finds the minimum and maximum elements of an array and removes the from the array

HOMEWORK :

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

ax^5+bx^4+cx^3+dx^2+ex+f

 

4

Functions  and Arrays

 

LECTURE WORK :

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

b) Writing a program that generates 4 random even numbers from 38 to 83 different from each other 

 

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 :

a) 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 [a+b^3]-c. Finally plot the 3D graph

b) Writing a function that checks whether the number is prime or not. Then using this function to write a program that finds 20 prime numbers greater than 100

c) Creating 10x10 array and converting the elements of the array to 0 if the number is even and 1 if the number is odd 

 

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

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 :

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. 

7

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

 

LECTURE WORK :

 

a) 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.)

b) 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 :

 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.

 

8

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

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 :

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.

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 :

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 10 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.

 

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 :

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.

 

12

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

 

LECTURE WORK :

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

b) Writing tribonacci sequence. Tribonacci sequence terms are as follows: 1 1 2 4 8 15 29 56... and goes like this

HOMEWORK :

a) Write a program to control if a given vector includes the Fibonacci sequence or not.

b) Take an input N value from the user. Create a N-valued vector which includes only even and non-recurring random numbers ranging in between 27 to 63. For each number in the array, calculate the absolute difference from the ones digit value and the tens digit value. If this difference is smaller than 5, then place this number into another array. Finally, display this final array on the screen.

c) Write a program to reverse the digits of the given number.

d) Store the numbers from 1 to 1000 to the following arrays

    -1st array includes non-prime and non-perfect numbers

   -2nd array includes non-prime and perfect numbers

   -3rd array includes prime and non-perfect numbers

   -4th array includes prime and perfect numbers

 

13

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

 

LECTURE WORK :

Old exams / Recitation