should i us if/eslse if or int.
1 view (last 30 days)
I am having trouble with a code that is depicting days. i have three different rates. one being the daily rate used for 1-2.4 days. weekly rate starts from 2.5-17.63. and monthly goes from 17.65-30 days.
At first thought, the If/Elseif seems the most logical until it becomes something like 34 days, where i need the program to depictthat it is 34 days and now it needs to add the monthly and the weekly or 61 days - where it now needs to depict two monthly rates and then a daily rate. and so on and so forth
I dont know if someone has any advice or more knowledge on the intergration function and if that is a route i should consider taking instead.
Thank you in advance for any help.
Kshitij Chhabra on 4 Aug 2021
From my understanding of the question, you want to implement an if/else if ladder to calculate the rate which you should use for the following day. An approach which I can suggest is using the mod function along with division in MATLAB.
In your case, lets say that you find the rate for 68 days and you have a dailyRate, weeeklyRate and a monthlyRate, you can compute the final rate as follows:
elseif(days>=2.5 & days<=17.63)