Why do I keep getting an undefined function or variable error?
Ältere Kommentare anzeigen
Here is the problem I'm trying to answer:
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%
I KEEP GETTING AN UNDEFINED FUNCTION OR VARIABLE ERROR (check picture below)
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

Antworten (1)
Star Strider
am 20 Okt. 2017
See if copying it to:
C:\Users\cmcmechan\Documents\MATLAB\
solves the problem. I don’t know how you have your path set up, however your function does not appear to be in your MATLAB path.
4 Kommentare
Connor McMechan
am 20 Okt. 2017
Star Strider
am 20 Okt. 2017
MATLAB is set up to only search for items (code, data, etc.) in certain directories known as its ‘search path’. There are several functions to work with it, one of which is the path (link) function.
See the discussion on What Is the MATLAB Search Path? (link) for details. (This and similar information are linked to at the end of the path documentation page.)
Connor McMechan
am 20 Okt. 2017
Star Strider
am 20 Okt. 2017
As always, my pleasure.
If my Answer helped you solve your problem, please Accept it!
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!