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

MATLAB Code IN MATLAB, Write a function with the header: [balance, rate] = myROI

ID: 1996843 • Letter: M

Question

MATLAB Code

IN MATLAB, Write a function with the header: [balance, rate] = myROICalculator(balance)

which calculates the Return on Investment (ROI) after one year with the following interest rate table:

Balance Interest Rate $10000 or less 1.1% Greater than $10000 but less than or equal to $25000 2.2% Greater than $25000 3.7%

Test Cases:

>> [a, b] = myROICalculator(5000) a =   5055 b = 0.0110

>> [a, b] = myROICalculator(35000) a = 36295 b = 0.0370

>> [a, b] = myROICalculator(15000) a = 15330 b = 0.0220

>> [a, b] = myROICalculator(25000) a = 25550 b = 0.0220

Explanation / Answer

The code of function file is as follows:

function [ a,b ] = myROICalculator( balance )
%This function calculates ROI and interest rate
%   Detailed explanation goes here

if balance <= 10000
   a=balance+(balance*0.0110)
   b=0.0110
elseif balance > 10000 & balance<= 25000
    a=balance+(balance*0.0220)
   b=0.0220
else
   a=balance+(balance*0.0370)
   b=0.0370
end
end