MA1MSP: Mathematical and Statistical Programming
Assignment 1
This assignment counts to 10% of the total marks of this module. Full marks of this
assignment can be gained from complete answers to ALL questions and submitting
the MATLAB script file to my email address john.evans.18@nuist.edu.cn before 12pm
(noon) 22nd March, 2019 (Friday).
Write a MATLAB script with the file name of ’MSP assign1 StudentID.m’, where ’StudentID’ is your
Student ID number, which can perform the following actions:
Write your own code to convert the following 8-digit binary numbers into decimal numbers
– a = 00001101
– b = 00110100
– c = 10100001
and allow the output be shown in the Command Window (i.e., on the screen). No marks will
be given if using a built-in Matlab function (such as bin2dec) for the conversion.
[2 marks]
Plot the following two functions
y(x) = b ln(x a) + c, x ∈ [30, 30]
and
r(θ) = bθa/c, θ ∈ [0, 4π]
in the same figure (in the xy plane). Here the coefficients a, b and c are the decimal numbers
generated from the above conversion. Note that you need to convert the second function from
polar to Cartesian coordinates.
[4 marks]
The plots should also have the following features:
– The first curve is of solid line, star (*) markers and red colour.
– The second curve is of dotted line, square markers and blue colour.
– Legends for the two curves ’y(x)’ and ’r(theta)’.
– y-axis labelled as ’y(x)’.
– x-axis labelled as ’x vaules’.
– Title ‘Plotting functions’.
[2 marks]
1
Add comments at proper places in the script to indicate
– ‘This assignment is submitted as part of the course on Programming with MATLAB for
class X.’ Here, ‘X’ refers to the class to which you belong, e.g. MAM2.
– ‘This part of code converts binary numbers to decimal numbers.’
– ‘This part of code performs the plotting.’
[2 marks]
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。