Why do I keep getting an undefined function or variable error?

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

回答 (1 件)

Star Strider
Star Strider 2017 年 10 月 20 日

0 投票

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 件のコメント

Connor McMechan
Connor McMechan 2017 年 10 月 20 日
Im new to matlab, so I'm not really sure what a user path is.
Star Strider
Star Strider 2017 年 10 月 20 日
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.)
You can easily move it to your MATLAB search path with the movefile (link) function.
Connor McMechan
Connor McMechan 2017 年 10 月 20 日
Thank you, I really appreciate the help
Star Strider
Star Strider 2017 年 10 月 20 日
As always, my pleasure.
If my Answer helped you solve your problem, please Accept it!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索

質問済み:

2017 年 10 月 20 日

コメント済み:

2017 年 10 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by