Question

In: Computer Science

Part A - For Loops (7 Marks) Charlie, an avid mountain biker, has purchased a new...

Part A - For Loops

Charlie, an avid mountain biker, has purchased a new multisport watch that measures data such as horizontal position, time, heart rate and elevation. The associated software for the watch allows for users to design their own apps that record new measurements. Charlie is interested in measuring their elevation gain and total distance travelled.

1. Write a MATLAB function that recieves vectors for horizontal position and elevation and outputs a plot of elevation vs. horizontal position. (1 mark)

2. Write a function that receives the vectors for horizontal position and elevation and outputs total distance travelled. You can assume that each point has been recorded sufficiently close together that a linear approximation incurs insignificant error. Your solution must use a for loop and is not allowed to use the in-built sum or diff functions. Hint: Calculate the distance between each coordinate and sum these distances together.

3. Elevation gain is a term used to describe the total vertical distance climbed up during uphill sections (downhill elevation changes are ignored). Write a function that receives an elevation vector and calculates the total elevation gain for the trip. Your solution must use a for loop and is not allowed to use the in-built sum or diff functions.

Solutions

Expert Solution

function partAQ1(xPosition,Elevation)
plot(xPosition,Elevation)
%uncomment the below 3 lines to show title and labels
% xlabel('Horizontal Position')
% ylabel('Elevation')
% title('Elevation vs Horizontal Position')

%%%%%%%%%%%%%%%%%%%%%%%%%%

function Distance = partAQ2(xPosition,Elevation)
Distance = 0;
for i = 1:length(xPosition)-1
    %if xPosition is x coordinates, and Elevation is y coordinates
    %distance between 2 points is given by sqrt((x1-x2)^2 + (y1-y2)^2)
    dist = sqrt((xPosition(i+1)-xPosition(i))^2 + (Elevation(i+1)-Elevation(i))^2);
    Distance = Distance + dist;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%

function ElevationGain = partAQ3(Elevation)
ElevationGain=0;
for i=1:length(Elevation)-1
    if Elevation(i+1)>Elevation(i)%add only if there's an increase
      ElevationGain = ElevationGain + (Elevation(i+1)-Elevation(i-1));
    end
end


Related Solutions

Charlie Dew purchased a new personal watercraft on October 24, 2020 from the local marina for...
Charlie Dew purchased a new personal watercraft on October 24, 2020 from the local marina for a cost of $5000. He was sent an invoice with the following terms: 2% discount if paid in full by November 24, 2020, otherwise the full amount is due by February 24, 2021. Suppose Charlie can find a lender who will lend him the money he needs on November 24 at the following simple interest rates: 6% for the first 20 days, 7% for...
This question has 7 parts. Each of the 7 parts (Part A - Part G) has...
This question has 7 parts. Each of the 7 parts (Part A - Part G) has a dropdown list of possible answers. Choose the best answer from the dropdown list for EACH part of the question below. Your analysis will focus on the variables "Current residence" and "Gender" Researchers are interesting in examining if there is an association between a person's gender and their current residence type, conduct a two variable chi-square test to test whether there appears to be...
Use the following information to answer Part (a) and (b) Charlie, a single taxpayer, has gross...
Use the following information to answer Part (a) and (b) Charlie, a single taxpayer, has gross income of $115,000. He has following expenses for 2019: - Rent for his apartment: $14,400 - Advertising and maintenance expenses for a rental property he owns in the amount of $1,800. - Moving expenses to change jobs (assume Tyler is not reimbursed for his expenses) : - Cost to move furniture and home furnishings: $3,600 - House-hunting expenses: $800 - Tyler traveled 200 miles...
Question 1 Week 7 (7 marks) Jaguar Ltd purchased a machine on 1 July 2016 at...
Question 1 Week 7 Jaguar Ltd purchased a machine on 1 July 2016 at the cost of $640,000. The machine is expected to have a useful life of 5 years (straight-line basis) and no residual value. For taxation purposes, the ATO allows the company to depreciate the asset over 4 years. The profit before tax for the company for the year ending 30 June 2017 is $600,000. To calculate this profit the company has deducted $60,000 entertainment expense, and $80,000...
Question1 (7 marks) You are the new CFO of Risk Surfing Ltd, which has current assets...
Question1 You are the new CFO of Risk Surfing Ltd, which has current assets of $7,920, net fixed assets of $17,700, current liabilities of $4,580 and long-term debts of $5,890. Required: a.   What are the three important questions of corporate finance you will need to address? Please briefly explain them and indicate how they are related to the areas in the balance sheet of a company. (1 mark) b.   Calculate owners’ equity and build a balance sheet for the company?...
Question 1 (10 marks) Computer Whiz Pty Ltd (Computer) has four directors. Charlie is one of...
Question 1 Computer Whiz Pty Ltd (Computer) has four directors. Charlie is one of the directors. Computer’s constitution provides that all transactions over $5,000 need to be approved by a majority of directors. Charlie enters into a contract for $7,000 with Simone to take photos to update the company website. Simone sends the bill to Computer who are refusing to pay on the basis they never authorised the contract. Advise Simone as to which statutory assumptions in the Corporations Act...
Part A: (6 marks) Lower Niagara Company purchased equipment in 2021 for $80,000 and estimated an...
Part A: Lower Niagara Company purchased equipment in 2021 for $80,000 and estimated an $8,000 residual value at the end of the equipment's 10-year useful life. At December 31, 2027, there was $50,400 in the Accumulated Depreciation account for this equipment using the straight-line method of depreciation. On March 31, 2028, the equipment was sold for $21,000. Required Part A: Prepare the appropriate journal entries to update accumulated depreciation and then to remove the equipment from the books of Lower...
QUESTION 1 (7 marks) A machine that caps soda bottles was purchased April 1, 2020 for...
QUESTION 1 A machine that caps soda bottles was purchased April 1, 2020 for $96,000; estimated useful life of 10 years and salvage value of $6,000. It is also estimated that the machine could cap a total of 360,000 bottles over its entire life. Calculate depreciation expense under the following independent assumptions: 1. Straight line depreciation, for the year ended Dec. 31, 2020. 2. Double declining balance depreciation for the year ended Dec. 31, 2020 and 2021. 3. Units of...
Question No: 2 10 Marks Case (a) The National Ferries Company in Oman purchased a new...
Question No: 2 10 Marks Case (a) The National Ferries Company in Oman purchased a new ferry at a cost of OMR 320,000. The facilities available in that ferry were modern and long lasting. The useful life of the ferry was estimated for 20 years. At the end of the 8th year the ferry’s wireless and navigation system requires replacement. The company felt that the maintenance cost of the wireless and navigation system was very high and they decided to...
Mountain Distribution has decided to analyze the profitability of five new customers. The company has the...
Mountain Distribution has decided to analyze the profitability of five new customers. The company has the following​ activities: Activity Cost Driver Rate Order taking $80 per purchase order Customer visits $80 per customer visit Deliveries $4.00 per delivery mile travelled Product handling $0.85 per case sold Expedited deliveries $335 per expedited delivery. It buys bottled water at ​$12.20 per case and sells to retail customers at a list price of $14.50 per case. Data pertaining to the five customers​ are:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT