Exercises - VMinhoto/workshop-matlab GitHub Wiki

Exercises

1. Initiation 🌱

Write a program which will find such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included).

2. The Matrices Begin 🔢

Write a function which takes 2 digits, X and Y, as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Example:

[1 2 3] 
[2 4 6]
[3 6 9]

3. All I want for Christmas 🎄

Is it too soon for the Christmas? Not in our Matlab workshop!

Write a program that asks the user how big he wants his tree and then draws it. At the end, you should have something like this.

Enter number of rows: 3
  *
 ***
*****
  | 

4. Follow the robots 🤖

A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following:

UP 5
DOWN 3
LEFT 3
RIGHT 2

The numbers after each direction are steps. Write a program to read directions from the workspace, while the user don't input end, and compute the distance from current position after a sequence of movement and original point. If the distance is a float, then just print the nearest integer.

NOTE:User input should be U5 for Up 5, D3 for Down 3, L3 for Left 3 and R2 for Right 2

Example: If the following tuples are given as input to the program:

'U5'
'D3'
'L3'
'R2'
'end'

Then, the output of the program should be: 2.

5. Meet my home 🗻

I am from far and I miss my home. I have developed a function, homeMountain, that returns a 49*49 Matrix with data that displays the height from the my hometown. Can you make a 3D plot of it?

NOTE: you can find the function in the repository.

6. Feel my ❤️ beat!

Last week I went to the doctor and done an ECG. He told me I had some anomaly, but I think he is a bit dumb 😅 . So I decided to ask for the data and plot it to check it myself. He send me the data on a excel file. You can find it in the repository given. Can you plot this data for me with the correct axis labels?

For extra merit can you normalize the data so it has a 0 mean and pinpoint the several maximum Heart Beat peaks?

HINT: You should do something using the mean of all vector values. Also look up the annotation documentation page.