Choice-Dependent Multi-Variable Anonymous Function
Show older comments
A little background information. There are two parking lots, one which is long term and one which is short term. For the short term lot, the first 30 minutes are free, and each additional 20 minutes or fraction thereof is $1. The daily maximum is $25. For the long term lot, the first hour is $1 and each additional hour or fraction thereof is $1. The daily maximum is $6 and the weekly maximum is $42.
I have to create an anonymous function y=cost(L,W,D,H,M). L can be either 'long' or 'short', while the other values are numerical. W is the number of weeks, D is the number of extra days, H is the number of extra hours, and M is the number of extra minutes. I cannot for the life of me figure out how to properly do this without using for-loops and if statements, and even then it isn't working properly. Can anyone tell me how I can implement the string value of L into the function alongside numerical values?
Any help would be greatly appreciated.
Thanks.
Accepted Answer
More Answers (0)
Categories
Find more on Language Fundamentals 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!