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일
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

Im new to matlab, so I'm not really sure what a user path is.
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.
Thank you, I really appreciate the help
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