Hi! I need a suggestion about which method I should use in doing this task. Before, I use Excel VBA to do this and it worked well. Then, I have to change my method to Matlab and I got confused as I am really new in this programming software. I have a data in the form of table, consist of datetime and flow (numeric). The flow is dynamic (like the plot in peak analysis), as it has both zero and non zero values in it. I need to calculate the total events of the condition with zero values (dry period) and the duration of each events. Do you have any suggestion for me to do it in matlab? Here is what I do in Excel VBA (picture attached)
1. I add one column contain sequence number from the first row until the last row beside the datetime data and flow data.2. I filter the data based on the flow. If it is not zero, I delete the flow and other data in its row.3. Now, the sequence number may not be in order form because some have been deleted. From this sequence number, I then make a column more beside sequence number column for unique number. The first row would be'1', and if it is still in sequenced form, it remains 1, but if it jumps to three number above or more, it should be '2' and this pattern continue until the last row.4. After I got all the unique number which represents the event I need, I use pivot table to find maximum and minimum datetime of each event, then I substract it. That way I can find the duration of each event.
Do you have any suggestion for me to do it in matlab (with matlab code?) or should I also do the same as in ExcelVBA? In matlab I also have the table form consist of the data. I really appreciate for your help. Thank you so much in advance.
Best Answer