首页 > > 详细

ECMM171P辅导、MATLAB程序语言辅导

ECMM171P Programming for Engineers
MATLAB assignment 2 / Programming Challenge
This assignment should be completed by 16.00 on Thursday 3rd November. Please read
the instructions carefully. The assignment consists of four tasks in total, but task 2 has two
sub-tasks. Marking scheme is provided below each task. Please ensure that your programs run
without any error in MATLAB versions R2019 and later and make sure you submit MATLAB
(.m) files, screenshots or simple text files will not be marked. This is not a group assignment,
so ensure that you submit your own work.
When you finish with everything, add all your programs, in a zip file (compress them) and
submit through BART.
1. Write a program (script) that asks the user to enter the score of a coursework (between 0
and 100). The program should then display this score and the corresponding grade found
according to,
Percentage Grade
score ≥ 70 A
score ≥ 60 AND ≤ 69 B
score ≥ 50 AND ≤ 59 C
score ≥ 40 AND ≤ 49 D
score < 40 F
[10%]
2. The number π can be approximated by the following series,
π = 4(1? 1
3
+
1
5
? 1
7
+ ...) (1)
Write a program (script) that uses a while loop to evaluate the above series and
calculates the value of π. To terminate the loop, use the condition that the next
term to be evaluated in the series is less than or equal to 1× 10?6. [20%]
Your program should save all the estimates of π in a variable called ‘ pie ’ and then
plot the first 100. [5%]
3. Write a Matlab function which takes as an input two numbers a and b, and checks whether
the digits of b can be rearranged to give a (or vice versa). For example, the digits of
numbers 123 and 321 can be rearranged to give the same number. The function should
produce as an output a single variable with a value of 1 when the the rearrangement is
possible and 0 when it is not. HINT: consider converting your number to a string to
identify each digit of the number. [30%]
1 TURN THE PAGE
4. Write a function which takes as an input an array of numbers, and then produces another
array which has the numbers mixed according to the following:
If the size of the array is even, then the function separates the array into two equal
parts, and then interleaves the two parts.
If the size of the array is odd, then it separates the array into two parts of size
(n+1)/2 and (n-1)/2, where n is the size of the array, and then interleaves the two
parts.
As an example, consider you are given the array containing 5 numbers: 1 2 3 4 5, then
the result of the mixing will be: 1 4 2 5 3 Please consider that the input will be a row or
column array (and not a matrix). [25%]
5. Your code will receive an additional [10%] of discretionary marks relating to coding style,
comments, structure of code and efficiency. Programs with no comments will receive 20%
less than what would normally be awarded.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!