Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(b) Write a MATLAB script that asks the user to type an even number N between 4

ID: 3909248 • Letter: #

Question

(b) Write a MATLAB script that asks the user to type an even number N between 4 and 20. After this, your script must create a NxN matrix called A in which the middle two rows, and the middle two columns are 3's and the rest are 8's. For example, if the user types 6, your script will create the matrix shown below 8 8 3 3 8 8 8 8 3 3 8 8 8 8 3 3 8 8 8 8 3 3 8 8 [9 marks] (c) The file fl.m contains the following code function z-f1(x,y) - x/2+y/3 end After you run the 3 commands below, what will be the value ofa y-fl(z,x); >> a = [x, y, z); 4 marks] Question 4 A courier company accepts packages for 1-day delivery up to a maximum ship- pable weight of 80 kg. Its delivery fees are calculated according to the following rules Up to 1 kg... $20.00 overweight charge if 50 kg exceeded$15.00 Assume we have written a MATLAB function to calculate and return the cost as per the above rules; the first line of our function is function cost-postage(weight) Note, if the package is more than the maximum shippable weight then the func- tion returns -1 (a) Write a MATLAB script that asks the user to input the weight of a parcel, calls postage and displays a message describing the parcel cost. The script should keep asking for and processing new values until the user types a negative or zero weight. Note in this part of the question you do not have to define the body of the postage function -you just have to write code that calls it. [5 marks] (b) Write the body of the MATLAB function postage as defined above [7 marks] (c) Provide the list of tests cases you will use to check your postage function is correct. [4 marks]

Explanation / Answer

Ansswering first question as per chegg policy. Please post rest of the question in a new question.

b)

x = input("Enter an even number between 4 and 20: ");

if (x >= 4 && x <= 20 && mod(x, 2) == 0)
A(1:x, 1:x) = 8;
c = x/2;
for i = c:c+1
for j = 1:x
A(i, j) = 3;
end
end
  
for j = c:c+1
for i = 1:x
A(i, j) = 3;
end
end
A   
else
disp("Number enetered is not valid")
end

Sample run

c)

value of x, y, z will not change because variable are passed by value