1. Homepage
2. Programming
3. Practical 2 Matlab Basics - Vectorisation and Decisions

# Practical 2 Matlab Basics - Vectorisation and Decisions

Matlab BasicsVectorisation and Decisions

# Practical 2 Matlab Basics - Vectorisation and Decisions

## The IF - ELSEIF - END Conditional statements

Q1. Write a MATLAB program to evaluate a function f (x, y) for any two user-specified values x and y. The function f (x, y) is defined as follows:

Q2. Suppose that you are writing a program that reads in a numerical grade and assigns a letter grade to it according to the following table:

``````95 < grade           A
86 < grade ≤  95  B
76 < grade ≤  85  C
66 < grade ≤  76  D
0 < grade ≤  66  F``````

Write an IF construct that will assign the grades as previously described using multiple elseif clauses.

## The WHILE loop

Q3. Write a program to compute the sum of the series 12 + 22 + 32 + ··· such that the sum is as large as possible without exceeding 1000. The program should display the sum and how many terms are used in the sum.

First, please don’t use the inbuilt function SUM. Then, after getting the number of terms, please solve this problem using vectorisation.

Q4. The nth Fibonacci number is defined by the following recursive equations f (1) = 1 f (2) = 2 f (n) = f (n − 1) + f (n − 2)

Therefore, f (3) = f (2) + f (1) = 2 + 1 = 3, and so forth for higher numbers.

Write an M-file to calculate and write out the nth Fibonacci number for n > 2, where n is input by the user.

### More practical problems

Q5. Let the user enter an integer n greater than one, and then compute the sum of the first n terms of the harmonic series. Please provide two solutions, one uses looping and the other uses vectorisation. 1 1 1 1 1 1 1 + 2+3+4+5+6+7+⋯

Q6. Find the sum of the first 10 terms of the geometric series. Please provide two solutions, one uses looping and the other uses vectorisation. 1 1 1 1 1 1 + 2+42+6+8+10+⋯

Q7. Find the sum by first creating two vectors for the numerators and denominators.

3 7 11 15 19 10 20 30 40 50

Q8. A engineer measured the radius and height of 10 cylinders, listed in Table 1. Find the volume for each cylinder, mean value and standard deviation of the volume. Table 1 Measurement of cylinders

0.051 1.111
0.052 1.121
0.049 1.132
0.048 1.113
0.047 1.082
0.053 1.091
0.051 1.102
0.052 1.114
0.049 1.075
0.051 1.144

## Get Expert Help On This Assignment

#### Scan above qrcode with Wechat

Matlab Basics代写,Vectorisation and Decisions代写,Matlab Basics代编,Vectorisation and Decisions代编,Matlab Basics代考,Vectorisation and Decisions代考,Matlab Basicshelp,Vectorisation and Decisionshelp,Matlab Basics作业代写,Vectorisation and Decisions作业代写,Matlab Basics编程代写,Vectorisation and Decisions编程代写,Matlab Basicsprogramming help,Vectorisation and Decisionsprogramming help,Matlab Basicsassignment help,Vectorisation and Decisionsassignment help,Matlab Basicssolution,Vectorisation and Decisionssolution,