首页 > > 详细

代写 HW 1: MATLAB 代做mydist.m

项目预算:   开发周期:  发布时间:   要求地区:
HW 1: MATLAB
Read and execute the commands described Sections 1–10 of Basic Concepts in Matlab
(including creating the function mydist.m) and then answer the following questions (you can
diary command in Matlab (see help diary)
to record your commands and results to a text file):
1. Given the array x = [3 1 5 7 9 2 6], provide the single command (one line of
code with at most one assignment (i.e., equals sign =)) needed to perform the following
actions. Unless noted, all of the actions should not modify x; instead, the result of the
action will be assigned to the default variable ans.
(a) Extract the forth element from x
(b) Extract all but the last element from x
(c) Extract the first, third, first, fifth, and first element from x
(d) Reverse the elements of x
(e) Calculate the sum of all of the elements of x
(f) Calculate the sum of the first to the ith element of x, for all elements of x
(g) Set the second and sixth elements of x equal to zero
(h) Modify x by deleting its third element
(i) Using the result from (h), modify x by converting it into a 2  3 matrix, where the
first row of the matrix has the first three elements of x
2
2. Let x = [6 2 1 4] and A = [2 7 9 7; 3 1 4 6; 8 1 2 5], provide the
single command needed to:
(a) Add x to each row of A
(b) Add x to the sum of each column of A
(c) Add the sum of x to each element of A
(d) Calculate the sum of the element-by-element product of each row of A and x
3. Given that x = [1 5 2 7 9 0 1] and y = [5 2 2 6 0 0 2], provide the
single command needed to:
(a) Extract from x those values that are greater than the corresponding values of y
(b) Extract from x those values that are both greater than the corresponding values of y
and less than 6
(c) Extract from x those values that are either less than 2 or greater than 6
(d) Modify y by adding 1 to each of its nonzero values
(e) Divide each element of y by the corresponding element of x as long as the element of
x is nonzero (to avoid dividing by zero)
(f) Modify y by setting all of its zero values to 1
4. Modify the Minimum-Distance Location example in Basic Concepts so that it can be used
to find the location that minimizes the maximum distance traveled between x and the three
points in P.
5. Modify the Minimum-Distance Location example in Basic Concepts so that it can be used
to find the location that minimizes the sum of distance traveled assuming that 3, 2, and 4
trips, respectively, are made between x and the three points in P.
软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!