Reference to a cleared variable lot. Error in parking (line 13) switch lot
1 view (last 30 days)
Show older comments
function cost = parking(lot,timeinminutes)
menu('Select your desired parking lot: ','L','S');
switch lot
case 'L'
disp('How long, in minutes, will you park?')
if timeinminutes<=60
cost=1;
0 Comments
Accepted Answer
Joseph Cheng
on 3 Jul 2014
Edited: Joseph Cheng
on 3 Jul 2014
if lot is being defined within the function you don't need to have it as an input. as what ever you're putting in that variable "slot" will be overwritten immediately by the input();
How are you calling the parking() function from the main program?
2 Comments
Star Strider
on 3 Jul 2014
@David —
1. The menu call needs an output.
2. If that’s the entirety of your code, you’re missing at least two end statements, one for the switch ... case block and one for the if block. Please post the entirety of the part of your code that is throwing the error.
More Answers (0)
See Also
Categories
Find more on Historical Contests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!